admin管理员组文章数量:1334668
I'm getting an error using moment-timezone
with America/Sao_Paulo
trying to parse date with America/Sao_Paulo
offset. 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
.
Am I missing something or did I initialize dateMoment
wrong?
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);
console.log(dateMoment.format());
console.log(moment.tz(timezone).format('Z'));
<script src=".js/2.10.6/moment.min.js"></script>
<script type="text/javascript" src=".js"></script>
I'm getting an error using moment-timezone
with America/Sao_Paulo
trying to parse date with America/Sao_Paulo
offset. 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
.
Am I missing something or did I initialize dateMoment
wrong?
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);
console.log(dateMoment.format());
console.log(moment.tz(timezone).format('Z'));
<script src="https://cdnjs.cloudflare./ajax/libs/moment.js/2.10.6/moment.min.js"></script>
<script type="text/javascript" src="http://momentjs./downloads/moment-timezone-with-data.js"></script>
Share
Improve this question
asked Jun 10, 2019 at 13:27
Pedro ArantesPedro Arantes
5,3695 gold badges29 silver badges64 bronze badges
2
-
2
The output is correct, see Sao Paulo DST Changes, the offset in June is
-03:00
while the offset is-02:00
in January. – VincenzoC Commented Jun 10, 2019 at 13:32 - This has been fixed in moment/timezone 0.5.27 build. Upgrade your moment-timezone lib/js to see the effect. github./moment/moment-timezone/tree/develop/builds – Dnyaneshwar Harer Commented Jan 30, 2020 at 6:34
1 Answer
Reset to default 4On January 1st 2019, Sao Paulo was still on Summer Time. It was UTC-2 until February 17th.
Brazil abolished summer time going forward, but that hadn't taken effect yet.
本文标签: javascriptmomenttimezone AmericaSaoPaulo wrong timezone offsetStack Overflow
版权声明:本文标题:javascript - moment-timezone AmericaSao_Paulo wrong timezone offset - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742373646a2462728.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论