Page 1 of 1

Passing DatePicker a Date Object

Posted: Fri Jul 31, 2015 7:16 pm
by Mac Strait

Hi I am trying to display in a DatePIcker UI component a date that I previously saved in local storage.

What I was doing was storing it as UTC milliseconds and creating a date object as:

var in_date=new Date(stored_UTC);
then using date methods to get to a string like dd/mm/yyyy and trying to input that string into the datepicker.

Is there a better way, i.e. can I just pass date object directly to datepicker?


Passing DatePicker a Date Object

Posted: Mon Aug 03, 2015 5:24 am
by Serhii Kulibaba

Hello Mac,

Please use the following code:

$("[name=finish_datepicker] input").val("dd/mm/yyyy");

use here number values instead of "dd/mm/yyyy"


Passing DatePicker a Date Object

Posted: Tue Aug 04, 2015 3:02 pm
by Mac Strait

Hi Serge,

I might not have explained myself properly. I wanted to pass a Date object directly to the datepicker as in:

mydate= new Date();

And pass mydate directly - doesn't look like I can do that using .val(mydate). I read on the JQuery website that the setDate(date) method is available for a datepicker object. How can I use this method, as setDate will accept a date object so I can just pass mydate directly without having to convert to a string of the format "dd/mm/yyyy" before using .val().

Does that make sense?


Passing DatePicker a Date Object

Posted: Sat Aug 08, 2015 7:00 pm
by Serhii Kulibaba

Mac,

You can't use simple Date object for settings datepicker value: http://api.jqueryui.com/datepicker/#m...

You should convert Date's value to the string. Please look this topic: https://getsatisfaction.com/apperyio/...