简体   繁体   English

moment-timezone美国/ Sao_Paulo错误的时区偏移

[英]moment-timezone America/Sao_Paulo wrong timezone offset

I'm getting an error using moment-timezone with America/Sao_Paulo trying to parse date with America/Sao_Paulo offset. 我在使用America/Sao_Paulo moment-timezone尝试使用America/Sao_Paulo偏移量解析日期moment-timezone遇到错误。 I've created this code: 我创建了以下代码:

const date = "2019-1-1 23:30";
const format = "YYYY-M-D HH:mm";
const timezone = "America/Sao_Paulo";
const dateMoment = moment.tz(date, format, timezone);

The output of dateMoment is 2019-01-01T23:30:00-02:00 but I expect 2019-01-01T23:30:00-03:00 , since America/Sao_Paulo has offset -03:00 . dateMoment的输出为2019-01-01T23:30:00-02:00但我希望2019-01-01T23:30:00-03:00 ,因为America/Sao_Paulo偏移量是-03:00

Am I missing something or did I initialize dateMoment wrong? 我是否缺少某些东西或初始化dateMoment错误?

 const date = "2019-1-1 23:30"; const format = "YYYY-MD HH:mm"; const timezone = "America/Sao_Paulo"; const dateMoment = moment.tz(date, format, timezone); console.log(dateMoment.format()); console.log(moment.tz(timezone).format('Z')); 
 <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.min.js"></script> <script type="text/javascript" src="http://momentjs.com/downloads/moment-timezone-with-data.js"></script> 

On January 1st 2019, Sao Paulo was still on Summer Time . 在2019年1月1日, 圣保罗仍在夏季时间 It was UTC-2 until February 17th. 直到2月17日才是UTC-2。

Brazil abolished summer time going forward , but that hadn't taken effect yet. 巴西取消了今后的夏季时间 ,但尚未生效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM