问题描述
我正在利用时间来获取时间。 我正在用以下格式获取它:2019年2月21日星期四10:44:21 GMT + 0500(巴基斯坦标准时间) 但是,我需要03:44:21 PM格式。 谁能告诉我如何使用momentjs做到这一点?
1楼
Hamza Ahmed
1
已采纳
2019-02-21 12:28:03
您可以为此目的使用momentjs
。 moment().format()
moment().format('hh:mm:ss A')
有关更多详细信息,请访问
本地也可以用于转换出固定偏移模式:
moment.parseZone('2016-05-03T22:15:01+02:00').local().format('hh:mm:ss A');
2楼
SM Chinna
0
2019-02-21 12:33:17
获取您的TimeZone并使用以下方法转换时区:
let timeZone = moment.tz.guess();
let date = 'Thu Feb 21 2019 10:44:21 GMT+0500' // input date (other timezone)
let convertDate = moment(date).tz(timeZone) //converted Time