Unable to set date format

Hi,

I’ve my scheduler this way initiated:

cellRight.attachScheduler(null,"month", "scheduler_here"); scheduler.config.api_date="%Y-%m-%d %H:%i"; scheduler.config.default_date="%Y-%m-%d %H:%i"; scheduler.load("xml/calendarLoad.php");

When I’ve to read date from new event form, I see date format different from what I expected.
This is how I read dates:

	scheduler.attachEvent("onEventSave",function(id,data,is_new_event){
		var param = "idm="+id+"&title="+data.text+"&ds="+data.start_date+"&de="+data.end_date;
		alert(param);
   }     

And this is what I read from the alert:

idm=1394379943467&title=Nuovo Appuntamento&ds=Wed Mar 19 2014 00:00:00 GMT+0100 (CET)&de=Wed Mar 19 2014 00:05:00 GMT+0100 (CET)

What I’m doing wrong?
Thanks in advance,
Samuel

Hello,
Scheduler generates template functions from the string configs when it’s being initialized. That happens when you call .attachScheduler. Try to definine configs before that[code]scheduler.config.api_date="%Y-%m-%d %H:%i";
scheduler.config.default_date="%Y-%m-%d %H:%i";

cellRight.attachScheduler(null,“month”, “scheduler_here”);
scheduler.load(“xml/calendarLoad.php”);[/code]

data.start_date and data.end_date are js Date objects, not formatted strings. You can stringify them manually:var date_to_str = scheduler.date.date_to_str(scheduler.config.api_date); scheduler.attachEvent("onEventSave",function(id,data,is_new_event){ var params= [ "id="+id, "title="+data.text, "ds="+date_to_str(data.start_date), "de="+date_to_str(data.end_date) ].join("&"); alert(params); });

Thanks, it worked fine!
And what about date from dhtmlxform?

I’ve an item created this way:

it’s correctly shown but posted this format:
Wed Mar 19 2014 08:35:00 GMT+0100 (CET)

How to post the values in this format?
%Y%m%d%H%i

Thanks in advance,
Samuel

Which code you are using to get values from the form?
By default form returns date value as date object, if you need to get a string try to use

var values = form.this.getFormData(false, true);

If you are using datastore with the form, issue can be fixed by updating to the latest codebase ( there was a bug in older version )

I’m using the $_POST php function the read data from the submitted form:

imForm.send(phpCall, "post", function(loader, response){
						.....
				});

the var_dump($_POST[“date_start”]); is:
“Thu Nov 30 1899 00:00:00 GMT+0100 (ora solare Europa occidentale)”

Hi,

I managed the format on php side.
Now it works.

Thanks for the support.

Samuel

Hi

please try latest calendar updates, there was a problem in strToDate function
calendar_latest_2014_03_11.zip (52.1 KB)

one more fix :slight_smile:
minor_fix.zip (14.8 KB)