Reputation: 2111
I was playing with moment library in node and was trying to format dates:
moment().tz(timezone).format('dddd')
This formatting gives me the current day of the week like 'Tuesday'
Now, I want to format like: 'Tuesday May 2, 2017'
What will be the best way to format it this way using moment?
Upvotes: 1
Views: 88
Reputation: 31482
You can simply use moment format()
, in your case you have to use 'dddd MMMM D, YYYY'
where:
dddd
stands for the day of the week nameMMMM
stands for month's nameD
stands for the day of the monthYYYY
stands for the four digit yearHere a working sample:
var timezone = 'Europe/Rome';
console.log(moment().tz(timezone).format('dddd MMMM D, YYYY'));
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.13/moment-timezone-with-data-2012-2022.min.js"></script>
Upvotes: 1