I am trying to add the time zone in the below code,
const Timeformat = moment("2020-06-03T07:48:59Z", 'h:mm:ss A', "Asia/kolkata")
.utc()
.format('h:mm A zz')
do i need to change any format here??
but always i get output as
"3:18 AM Coordinated Universal Time"
Expected output is
"3:18 AM IST"
without a moment library, you can do as
let now = new Date('2020-06-03T07:48:59Z') let result = new Intl.DateTimeFormat('default', { hour12: true, hour: 'numeric', minute: 'numeric' }).format(now) console.log(result)
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.