admin管理员组

文章数量:1417411

What is the difference between

  new Date(2013,0,1)

and

  Date.parse("2013-1-1")

that breaks

Here is jsfiddle /

What is the difference between

  new Date(2013,0,1)

and

  Date.parse("2013-1-1")

that breaks http://api.jqueryui./datepicker/#method-setDate

Here is jsfiddle http://jsfiddle/tawVx/4/

Share Improve this question asked Nov 14, 2012 at 15:48 tomaszbaktomaszbak 8,2874 gold badges46 silver badges37 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 3

Date.parse() returns the number of milliseconds elapsed since January 1st, 1970, 00:00:00 UTC, not a Date object.

setDate() takes either a Date object or a string, not a number of milliseconds elapsed since the epoch.

The following code would work:

$("#datepicker").datepicker("setDate", new Date(Date.parse("2013-01-01")));

本文标签: javascriptjQuery UI datepicker setDate with new Date vs DateparseStack Overflow