Show Moment.js in different language versions
Using Moment.js , I am unable to figure out how to display the date in a specific locale (like Fr). Any help is appreciated.
<script>
var NowMoment = moment().format("dddd, MMMM Do");
// display value of moment object in #displayMoment div
var eDisplayMoment = document.getElementById('displayMoment');
eDisplayMoment.innerHTML = NowMoment;
</script>
+3
user1556571
source
to share
2 answers
Add the moment locales.js or locale / fr.js you need ...
moment.locale('fr');
var NowMoment = moment().format("dddd, MMMM Do");
// display value of moment object in #displayMoment div
var eDisplayMoment = document.getElementById('displayMoment');
eDisplayMoment.innerHTML = NowMoment;
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment-with-locales.min.js"></script>
<div id="displayMoment"></div>
+1
source to share
I believe that you:
<script>
var NowMoment = moment();
NowMoment.tz('Europe/Paris').format("dddd, MMMM Do");
// display value of moment object in #displayMoment div
var eDisplayMoment = document.getElementById('displayMoment');
eDisplayMoment.innerHTML = NowMoment;
</script>
I'm not 100% sure if it works as I can't test it. I got it from http://momentjs.com/timezone/
0
source to share