Reputation:
Using Moment.js, I can't determine the way to show a date in a defined locale (eg. 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>
Upvotes: 3
Views: 991
Reputation: 55
I believe you do:
<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 am not 100% sure it works as I am not able to test it. I got it from http://momentjs.com/timezone/
Upvotes: 0
Reputation: 777
Add moment+locales.js or the locale/fr.js that 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>
Upvotes: 1