How can i get the date of event for which form was opened?

Hi,
I want the date of event for which form was opened.

I have used scheduler._date to get date but i want the date in this format MM/DD/YYYY. How can i get date in that format?

You can use:

scheduler.getEvent(id).text

If you need any other property, you can also use

var ev = scheduler.getEvent(id); ev.some_property

You can configure your date overall:

scheduler.config.xml_date="%Y-%m-%d %H:%i";

Or if you want to make a function, you could possible do this:

function formatMyDate(myDate){
    var myMonth = new date(newdate).getMonth();
    var myDay    = new date(newdate).getDay();
    var myYear   = new date(newdate).getFullYear();
    var myNewDate = myMonth +'/' + myDay +'/' + myYear;
    return myNewDate;
}

alert(formatMyDate(scheduler._date));

Something like that - I have not tested it.

HI
I got the date in “Wed Apr 28 2010 11:22:32 GMT+0530 (India Standard Time)” but i want the date in MM/DD/YYYY format. With “date” i mean date on which me double clicked for creating an event.

I am getting the current date with the “scheduler._date” instead i want the date on which me double clicked to create an event.

Thanks in advance.
Shiju

I am not sure, maybe something like:

var eventDate = new date(formatMyDate(scheduler.getEvent(id).start_date));

Where the it is the current id (event) that you have double clicked on. Then you could attach this to the on double click or on event open. The events are listed here:

docs.dhtmlx.com/doku.php?id=dhtm … ler:events

Eg:

scheduler.attachEvent("onDblClick", function (event_id, native_event_object){ //any custom logic here });

So an example:

scheduler.attachEvent("onDblClick", function (event_id, native_event_object){
       var eventDate = new date(formatMyDate(scheduler.getEvent(event_id).start_date));
       alert(eventDate);
  });

Something like that?

Error: date is not defined

It was a suggestion of what to use, so I was hoping that you would modify it to work correctly - to give you an idea of a starting point.

Stanislav might be able to help on this one, as I am certianly no expert in JS.

Ya i am working on it. I just mentioned it.

Thanks alot blueevo. I have made changes on code its working.

A correction to my function (i had “newdate” instead of “mydate” in the code below):

function formatMyDate(myDate){
    var myMonth = new date(myDate).getMonth();
    var myDay    = new date(myDate).getDay();
    var myYear   = new date(myDate).getFullYear();
    var myNewDate = myMonth +'/' + myDay +'/' + myYear;
    return myNewDate;
}

alert(formatMyDate(scheduler._date));

Ah, great. Glad it got you going, well done.

i used new Date(); instead of new date(); Then it worked and also made the change you mentioned above.

Thanks.

Here is the code worked for me.

var edit_id = null;
var edit_date = null;
scheduler.showLightbox = function(id){
edit_id = id;
if (scheduler._new_event){
edit_date = formatMyDate(scheduler.getEvent(edit_id).start_date);
alert(edit_date);
}
else{

    }
}

// function return date in MM/DD/YYYY format
function formatMyDate(myDate){
var MM = new Date(myDate).getMonth();
if(MM < 10)
MM = “0”+MM;
var DD = new Date(myDate).getDate();
if(DD < 10)
DD = “0”+DD;
var YYYY = new Date(myDate).getFullYear();
var myNewDate = MM +’/’ + DD +’/’ + YYYY;
return myNewDate;
}

Thanks blueevo for your support.

I don’t know whether any other easy way to get this. Stanislav might be able to help on this one

Your welcome, I hope I can put back into the community what I get out. Nice of you to post it for all to see.

There maybe a better way of doing it, but at least it works for us, eh!? :wink:

Ya blueevo lets make it work then we opt other things…