Reputation: 129
I have the following code in my Angular app:
ctrl.getDate = function() {
console.log(ctrl.day.date); => 2017-12-06T05:00:00.000Z
return moment(ctrl.day.date).format('MMMM do YYYY'); => December 3rd
2017
};
What is going on here? The date passed is clearly 2017-12-06 but for some reason the '.format' method is changing it to a day 3 days earlier.
Upvotes: 2
Views: 58
Reputation: 19
As Aleksey said capitalisation matters, with "do" you take the day of week and with "Do" you'll have the day of month. https://momentjs.com/docs/#/displaying/format/
Upvotes: 1
Reputation: 4191
Capitalisation matters:
return moment(ctrl.day.date).format('MMMM Do YYYY');
Changing do
to Do
Upvotes: 1