With some help from some fellow stack users, I currently have this:
The JSON data gives me the {start.date} in YYYY-MM-DD formatting, but I would like to know how to implement a date change to:
Mon 01 Jan
asked Apr 29, 2012 at 0:42
redditor
4,4011 gold badge23 silver badges43 bronze badges
-
So, your real question is how do you format a date in javascript. Try stackoverflow.com/questions/1056728/…Hamish– Hamish2012年04月29日 00:56:41 +00:00Commented Apr 29, 2012 at 0:56
1 Answer 1
Convert your date string "2012-05-29" to Date object:
var parts = date.split("-");
var d = new Date(parts[0], parts[1], parts[2]);
Then use dateFormat from here:
return d.format("ddd dd mmm");
answered Apr 29, 2012 at 0:57
Pavel Strakhov
40.8k6 gold badges93 silver badges131 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
Steve Savoy
I believe you shouldn't need to split on the
date variable. You should be able to just pass in date as-is using new Date(date), and it will give you the correct date, assuming you ask for it in UTC.lang-js