I would like to change this date time format using momentjs
2017-02-01T00:00:00.000Z
to
02-2017 ( month-year )
How to change this date format to get month-year only using momentjs?
I have tried like this:
var MnthYr = moment(2017-02-01T00:00:00.000Z).format("MM-YYYY");
but I didn't get exact answer
js default date format to dd/mm/yyyy.
You can simply use format
Here a working sample:
console.log( moment('2017-02-01T00:00:00.000Z').format('MM-YYYY') );
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
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