Reputation: 3349
I have the below code I'm trying to formate with d3.time.format()
the date I am passing in as an example in the time
variable is Thu Dec 24 04:59:54
. According to the documentation, the d3 time formatter is strict and will return null
if the format()
parameters don't match the time that's passed in to be parsed, but as far as I Can tell, I am passing in the correct format, but still getting null.
time = "Thu Dec 24 04:59:54";
parseTime = d3.time.format("%a%b%e%H:%M:%S");
console.log("PARSE TIME" + parseTime.parse(time));
EDIT: This is the documentation that I'm using https://github.com/mbostock/d3/wiki/Time-Formatting#format
Upvotes: 1
Views: 486
Reputation: 21575
It's because your .format
isn't taking spaces into account, so you will want to change it to:
parseTime = d3.time.format("%a %b %e %H:%M:%S");
To work with your example. Or you can remove the space from the time
variable before applying .parse
.
Upvotes: 2