我的时间如下
moment(date).tz(TimeZone).format('h:mm a z')
1:02 p.m. EST
我想说的是
1:02 p.m. EDT
如何将其更改为日光节省时间
每当涉及日期或时间等问题时,如果您想获得量身定制的结果,它将有助于将代码重构为某种日期类。幸运的是,datejs一个处理日期和时间的JavaScript库可以帮助您。
参考显示日光节省时间,此示例为您提供了想要的东西。
gettimezoneabbreviation
Date.getTimezoneAbbreviation ( Number timezoneOffset, Boolean isDayLightSavingsTime ) : String
Returns a culture-specific timezone abbreviation based on a given offset and a boolean indicating whether daylight savings time is in effect.
Parameters
{Number timezoneOffset} The year.
{Boolean isDayLightSavingsTime} Whether the date instance is observing Daylight Saving Time (Summer Time)
Return Value
{String} The timezone abbreviation
Example
var today = Date.today(); Date.getTimezoneAbbreviation(today.getTimezoneOffset, today.isDayLightSavingsTime()); // "UTC", "GMT", "EST", "PDT", etc.
我在瞬间做不到
jun.tz('America/New_York').format('ha z'); // 8am EDT
dec.tz('America/New_York').format('ha z'); // 7am EST
在冬天,我一直认为