Reputation: 3301
Need to use Moment.js to format the below Date string.
Wed Sept 01 2017 04:33:01 GMT+0400 (+04)
I tried to use below but it didn't work
moment(e.dateVale, 'D MMMM D YYYY, hh:mm:ss a')
I referred http://momentjs.com/ but couldn't make it work.
Any help would be highly appreciated
Upvotes: 0
Views: 196
Reputation: 224
You need to use new Date
for creating a Date object from the String you're passing and then will enable you to use moment for formatting that Date object.
See this:
console.log(moment(new Date('Wed Sept 03 2017 06:33:01 GMT+0400 (+04)')).format( 'D MMMM D YYYY, hh:mm:ss a'));
Upvotes: 1
Reputation: 163
Try This:
console.log(moment('Wed Sep 06 2017 04:33:01 GMT+0400 (+04)', 'ddd MMM DD YYYY HH:mm:ss [GMT]Z').utc())
Day and date combination in the string provided by you is not correct and will give following error.
moment.invalid(/* Wed Sept 01 2017 04:33:01 GMT+0400 (+04) */)
Upvotes: 1