Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery UI Datepicker won't accept unix timestamp as default value

I have the Unix timestamp "1264529457", which translates into January 26, 2010, which is stored inside an input element named "america".

When initializing jQuery UI's Datepicker, I have the following code to set the default date:

defaultDate: $.datepicker.parseDate('@', $("input[name=america]").val()),

When I manually check to see what this comes out to in Firebug, it says "Thu Jan 15 1970 00:00:00 GMT-0500 (Eastern Standard Time) {}". Any idea what is wrong (the documentation for this function is a bit sparse, so I'm guessing I missed something)?

like image 522
Shawn Collier Avatar asked Dec 21 '22 19:12

Shawn Collier


1 Answers

Unix time is stored in seconds while Javascript uses milliseconds. Try multiplying your Unix timestamp by 1000 first.

like image 50
Ben Koehler Avatar answered Dec 26 '22 20:12

Ben Koehler