javascript - jQuery UI datepicker setDate with new Date vs Date.parse - Stack Overflow

What is the difference betweennew Date(2013,0,1)andDate.parse("2013-1-1")that breaks Here is

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")));

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745266005a4619459.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信