1

With some help from some fellow stack users, I currently have this:

http://jsfiddle.net/wZETP/

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

redditor
  • 4,196
  • 1
  • 19
  • 40
  • So, your real question is how do you format a date in javascript. Try http://stackoverflow.com/questions/1056728/formatting-a-date-in-javascript – Hamish Apr 29 '12 at 00:56

1 Answers1

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");

Working fiddle

Pavel Strakhov
  • 39,123
  • 5
  • 88
  • 127
  • 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. – Steve Savoy Apr 29 '12 at 04:43