Skip to content Skip to sidebar Skip to footer

Create Javascript Date Object From Date String

I would like to create a valid JavaScript Date object from the following string '010-10-25T23:25:55.847Z'. This string comes out of a PostGIS database 'timestamp with time zone' Da

Solution 1:

These links might help:

Javascript equivalent of php's strtotime()?

http://phpjs.org/functions/strtotime:554

Solution 2:

I'm not sure what that format it, but this will give you each number:

var results = "010-10-25T23:25:55.847Z".match(/\d+\.{0,1}\d+/g);
var year = results[0]; // maybe ?var month = results[1];
var day = results[2];
var etc...;
newDate(year, --month, day, hour, minutes, seconds);

or if it's kinda like UTC,

newDate(Date.UTC.apply(this, "010-10-25T23:25:55.847Z".match(/\d+\.{0,1}\d+/g)))

Post a Comment for "Create Javascript Date Object From Date String"