Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can jQuery DateTime parse this date?

I have a datetime of the form:

var myDate = "2013-06-07T00:00:00.000Z"

I wish to do

jQuery.datepicker.parseDate( "yy-mm-dd", myDate);

I don't care about the time part.

I get:

"Extra/unparsed characters found in date: T00:00:00.000Z"

Best I got so far is:

myDate = myDate.replace('T00:00:00.000Z', '');
myDate = jQuery.datepicker.parseDate("yy-mm-dd", myDate).toUTCString();

Please help.

like image 388
More Than Five Avatar asked Nov 29 '22 01:11

More Than Five


2 Answers

As it is ISO date format, I think you can call new Date(myDate) directly there is no need to parse it I think

var date = new Date(myDate);
like image 125
Arun P Johny Avatar answered Dec 15 '22 07:12

Arun P Johny


If you don't care about the time part, why not simply

jQuery.datepicker.parseDate( "yy-mm-dd", myDate.split("T")[0]);

Perhaps for general DateTime handling, have a look at moment.js

like image 20
Thomas Junk Avatar answered Dec 15 '22 09:12

Thomas Junk