Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

d3.js time parsing with milliseconds not working?

Is there a workaround to get D3.js to parse datetimes that have milliseconds included? I can't get this to work:

var parseDate = d3.time.format("%Y-%m-%dT%H:%M:%S").parse
parseDate("2011-01-01T12:14:35")
//that works

parseDate("2011-01-01T12:14:35.3456")
//returns null
like image 235
reptilicus Avatar asked Dec 11 '22 18:12

reptilicus


1 Answers

If your dateTime strings are already in that format, you don't need d3 to parse it into an actual date object.

For example:

new Date("2011-01-01T12:14:35")
# Sat Jan 01 2011 04:14:35 GMT-0800 (PST)

results in a correct date object.

like image 112
Gopherkhan Avatar answered Dec 27 '22 03:12

Gopherkhan