My code
nouveautes.forEach(function(nouveaute) {
console.log(nouveaute.createdAt.toLocaleString());
nouveaute.createdAt = nouveaute.createdAt.toLocaleString();
console.log(nouveaute.createdAt.getMonth());
nouveaute.createdAt = nouveaute.createdAt.getMonth() + " " + nouveaute.createdAt.getYear();
console.log(nouveaute.createdAt);
});
Output with 2 objects in array
2017-11-12 16:15:03
10
2017-11-12T15:15:03.000Z
2017-11-10 11:09:10
10
2017-11-10T10:09:10.000Z
I'd like to have :
In french :
// => Novembre 2017
Or if it's too difficult, in english :
// => November 2017
You can use Date.prototype.toLocaleDateString()
var date = new Date(Date.UTC(2017, 11, 20, 3, 0, 0));
var options = { year: "numeric", month: "long"};
console.log(date.toLocaleDateString("fr-FR", options));
// -> Novembre 2017
used moment.js library!
moment.lang('fr');
moment().format('MMMM YYYY');
https://momentjs.com/ https://www.youtube.com/watch?v=9JRvJ9aMLzc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With