Reputation: 615
This is my mongo db document
{
"creatorUid": "1234",
"creatorUserName": "userabc",
"title": "this is the first thread",
"description": "I like this thread and try to read it",
"threadOwner": "5451e21c7dfe65c6168fe612",
"createdAt": "2014-10-30T07:04:22.712Z",
"updatedAt": "2014-10-30T07:04:22.712Z",
"id": "5451e2f6d61cb61d18ed0122"
}
I want to format createdAt
as 2014-10-30
without time
Upvotes: 1
Views: 1420
Reputation: 350
You can format the date in several ways:
moment('2014-10-30T07:04:22.712Z').format('MM-DD-YYYY')
to get the date formatted in any way you want.var dateObj = new Date('2014-10-30T07:04:22.712Z');
var neededFormat = dateObj.getUTCFullYear() + '-' + dateObj.getUTCMonth() + '-' + dateObj.getUTCDay();
Upvotes: 2