简体   繁体   中英

Parsing date with milliseconds in d3js

Im trying to parse dates with this format 2016-07-27 04:45:33.881000000

into d3.js using

var parseTime = d3.timeParse("%Y-%m-%d %H:%M:%S.%L");

but it doesn't work, if I remove the milliseconds from the data it does work using this

var parseTime = d3.timeParse("%Y-%m-%d %H:%M:%S");

I got the .%L from the documentation, any idea why it might not be working?

I got this to work, not exactly your issue. %L only takes a 3 digit integer

%L - milliseconds as a decimal number [000, 999]. https://github.com/d3/d3-time-format/blob/master/README.md#utcParse

var d3 = require('d3');

var dateString = '2016-07-27 04:45:33.881';

var parseTime = d3.utcParse("%Y-%m-%d %H:%M:%S.%L");

console.log(parseTime(dateString));

The way I got it worked is by using 3 %L for 9 integer values of milliseconds shown below:

var date= "2019-02-19T00:00:00.0000000-04:00"

'%Y-%m-%dT%H:%M:%S.%L%L%L%Z'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM