[英]How to convert a given date/time for a specific timezone (not local) to UTC using moment.js and moment-timezone.js
[英]js : how to convert time to date (using moment)
我有moment(value).format("HH:mm")
正在轉換
2022-08-09T12:10:50.001Z
至
18:30
但我想以相反的方式做到這一點。
就像我從數據庫收到18:30:00
一樣,我想要這種格式2022-08-09T12:10:50.001Z
有什么解決辦法嗎?
那這個呢?
const time = moment('18:30:00', 'H:m:s');
console.log(time.toDate()); // Tue Aug 09 2022 18:30:00 GMT+0200
console.log(time.format("YYYY-MM-DDTHH:mm:ss.SSS[Z]")) // 2022-08-09T18:30:00.000Z
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.