Date & Time Picker Value

When using the date picker with time enabled, I can get the values displayed properly but when I post the form I only get the date value not the time. This is my code:

{ view:"datepicker", 
id:"datetime", 
name:"datetime", 
timepicker:true, 
label:"Date & Time", 
labelAlign:"right", 
stringResult:true, 
value:new Date(), 
format:"%d %M %Y - %H:%i", 
required:true }

I basically want to save the date and time to a db field and later retrieve it to display in a readable format ie. “24th April 1985 - 09:00”

Anyone have any ideas?

Do you apply any formatting to the datepicker result either on client or on server?
By default, datepicker equipped with a timepicker returns a date object that contains time info.

Hi Helga,
Thanks for replying. As you can see above the format is set to “%d %M %Y - %H:%i”. which displays in the field fine. But when I post that field all I get is the date in the format 2014-10-13. Which seems odd?

I didn’t notice that you use datepicker stringResult property.

When it is defined for the control, the date object return formatted with the help of a parseFormat of the locale in use. By default, North American locale is used, so the parseFormat is “%Y-%m-%d”.

But you can redefine this format, once for the whole application:

webix.i18n.parseFormat = "%Y/%m/%d - %H:%i";
webix.i18n.setLocale();

Then values will be return correctly.

http://webix.com/snippet/86ce1667

If you don’t want to redefine the format globally, remove stringResult and format the data while getting the form’s values.

That’s great, thanks for the info and demo!