The way SQL creates datestrings (such as with getdate()
) seems to differ from the way javascript handles datetime strings.
The Mozilla Devlopment networks says that datetime strings can be in ISO 8601 format.
This format is listed as being 2011-10-10T14:48:00
whereas your SQL string looks like 2011-10-10 14:48:00
.
All that needs to be done to make it a JS valid Datetime string is to replace the space with a T.
One way of doing this would be
var dateTime = "2013-12-31 09:09:49";
var jsValidDateTime = dateTime.split(" ").join("T");
Date.parse(jsValidDateTime); //output: 1388498989000
This information is valid as of Firefox 26 and Internet Explorer 11.