Reputation: 2221
I am converting json date from something like:
/Date(1224043200000)/
to
Mon Oct 22 16:37:04 UTC+0800 2012
using
var date = new Date(parseInt(dateData.substr(6), 10));
Is there any way to change the format to just show the month, date and year (Oct 22, 2012) instead of including the timezone and current day using similar if not the same code as the one I'm already using? Thanks so much.
Upvotes: 0
Views: 216
Reputation: 1201
You may want to use momentjs With something like this :
moment(1224043200000).format("MMM Do, YYYY");
Upvotes: 0
Reputation: 11508
You can try this:
var formattedDate = date.toString().split(" ").slice(1, 4).join(" ");
Upvotes: 0
Reputation: 63734
Checkout datejs which has powerful formatting capabilities. Using the toString FormatSpecifiers, you can provide a custom pattern like this:
new Date().toString("MMM dd yyyy");
Upvotes: 1