D3.js parsing time with milliseconds not working?
3 answers
Try looking for the formatting function d3.time.format.iso
shown on the wiki page: d3.time.format.iso .
+3
source to share
Include a format for parsing miliseconds that uses the% L source .
In your case:
var parseDate = d3.time.format("%Y-%m-%dT%H:%M:%S").parse
parseDate("2011-01-01T12:14:35") //that works
var parseDate = d3.time.format("%Y-%m-%dT%H:%M:%S.%L").parse
parseDate("2011-01-01T12:14:35.345") // works
Note that you have given 4 digits in milliseconds, which I think is incorrect if you are dealing with milliseconds. If you actually have 4 digits or 6 digits (microseconds) and you are only interested in milliseconds, you can filter out the last few digits. For example:
var parseDate = d3.time.format("%Y-%m-%dT%H:%M:%S.%L000").parse
parseDate("2011-01-01T12:14:35.345000") //that works
+1
source to share