[英]How to convert one time format to another in javascript using moment.tz?
我嘗試了各種方法,但無法使用moment.tz
將日期像1640638800
轉換為2022-11-27 16:00:00 America/New_York
時區格式。
我當前的代碼就像
import * as moment from 'moment';
var date= new Date(0);
date.setUTCSeconds(1640638800);
moment.tz(date.getFullYear()+"-"+date.getMonth()+"-"+date.getDay() + " 10:00:00", "America/New_York");
請幫忙
const ts = 1640638800
const m = moment.tz(ts, timezone)
const formatted = m.format('YYYY-MM-DD')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.