4

I am trying to parse a date string using d3.js. The format is like "2012-11-02T08:32:55-04:00"

You can see the console output below. Relavent API is here. D3 parser is stricter, as explains the doc. But, I was expecting '%Y-%m-%dT%H:%M:%SZ' as the format string. Which returns null. Any help appreciated.

Thanks.

format = d3.time.format('%Y-%m-%dT%H:%M:%SZ')
%Y-%m-%dT%H:%M:%SZ
format.parse("2012-11-02T08:32:55-04:00");
null
format.parse("2011-07-01T19:15:28Z");
Fri Jul 01 2011 19:15:28 GMT-0400 (EDT)
format = d3.time.format('%Y-%m-%dT%H:%M:%S%Z')
%Y-%m-%dT%H:%M:%S%Z
format.parse("2011-07-01T19:15:28Z");
null
format.parse("2012-11-02T08:32:55-04:00");
null

2 Answers 2

2

According to that API:

The following directives are not yet supported for parsing:
%j - day of the year.
%U - week number of the year.
%w - weekday number.
%W - week number of the year.
%Z - time zone offset, such as "-0700".
%% - a literal "%" character.

So you may be out of luck unless you remove the -[time_zone] part of the date.

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

Comments

0

This is no longer the case. Time zones were included in version 3.3.x of d3js.

d3js pull request: https://github.com/mbostock/d3/pull/1495

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.