Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javascript convert date string to date

How do I convert a string like this back to a date object?

"Thu Aug 18 2011 15:13:55 GMT-0400 (Eastern Daylight Time)"

Is there a more native way to store dates in javascript?

like image 708
mustapha george Avatar asked Dec 06 '22 19:12

mustapha george


2 Answers

I've tested this in IE7, IE8, IE9, chrome, and firefox 6:

new Date('Thu Aug 18 2011 15:13:55 GMT-0400 (Eastern Daylight Time)');

and it works.

like image 53
Joe Avatar answered Dec 10 '22 12:12

Joe


http://www.w3schools.com/jsref/jsref_obj_date.asp provides some insight, just package it up and send it through and youll find all sorts of conveniance provided.

var d = new Date(year, month, day, hours, minutes, seconds, milliseconds);
like image 38
Jake Kalstad Avatar answered Dec 10 '22 11:12

Jake Kalstad