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
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'));
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) */)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.