0

I am using d3js v4. The following is what my date string looks like:

var ds = "2019-02-18 22:38:18.327717";

I have set up my parser like so:

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

I then try and pass this string into parseDate like so:

var parsed_date_value = parseDate(ds);

But parsed_date_value is null after this. I figure there is some issue with the seconds part of my time format but it looks correct and I am not sure. Seems to me this date string matches this format im passing to d3.timeParse()

2 Answers 2

2

In your format string, you need to use microseconds (%f) instead of milliseconds (%L).

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

The complete reference is here: https://github.com/d3/d3-time-format#locale_format

Sign up to request clarification or add additional context in comments.

Comments

1

as per the documentation [https://github.com/d3/d3-time-format]:

%L - milliseconds as a decimal number [000, 999].
%f - microseconds as a decimal number [000000, 999999].

Here my L clearly was not on the range [000,999] like required by the docs. Instead it looks to be on the range [000000, 999999] so using the following fixed it:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.