d3 time format for YYYY-MM-DD ie. 2013-02-04
d3.js, date-format, javascript
Solution
I suspect the case of 'day' is incorrect. I can execute:
var parseDate = d3.time.format("%Y-%m-%d").parse;
parseDate( "2013-02-03" )
Without issue (it shows the correct Date). Likely, you need to change the code to:
data.forEach(function(d) { d.day = parseDate(d.day); });
(note, lowercase 'd' in 'day')
Problem
I am getting Uncaught TypeError: Cannot read property 'length' of undefined from my console at this line `var parseDate = d3.time.format("%Y-%m-%d").parse;` `data.forEach(function(d) { d.Day = parseDate(d.Day); });` here is how my date is formatted in my json object `day: "2013-02-04"`