Mac Strait
Posts: 0
Joined: Thu May 07, 2015 5:03 pm

Passing DatePicker a Date Object

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?

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Passing DatePicker a Date Object

Hello Mac,

Please use the following code:

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

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

Mac Strait
Posts: 0
Joined: Thu May 07, 2015 5:03 pm

Passing DatePicker a Date Object

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?

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Passing DatePicker a Date Object

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/...

Return to “Issues”