尝试从 Moment.js 迁移到 Dayjs,但唯一我无法工作的是时区缩写。
dayjs('2020-07-06T14:30:00.000-04:00').tz(dayjs.tz.guess()).format('Do MMM YYYY [at] HH:MMa z')
调用上面我会期望6th Jul 2020 at 08:07am EDT
但目前我只是在z
哪里EDT
。
我已经添加了 utc 和时区插件,但看不到任何其他插件需要使这项工作,我注意到在 Dayjs 格式文档中 z 未列出但搜索网络我看到很多人说解决方案是format('', {timeZone})
但格式没有不接受第二个论点??
看起来它已添加到 tz-plugin https://github.com/iamkun/dayjs/pull/325/files#diff-cad460a5e46a2a48c59e95356c683820R195
这是一个带有问题示例的代码沙箱: https ://codesandbox.io/s/hungry-knuth-r58gz
- - 编辑
看起来对 tz abbr 的支持已被删除:( https://github.com/iamkun/dayjs/pull/448/commits/e64c03cea79c579bcd3c4caf235b4724e56614d4