we have a dataset in Toronto Time and want to convert it to UTC, on the first of November, the time was changed from summer to winter time there.
The dataset contains the date and the hour of the day. On November the 1st it has exactly 24 rows, (0-23) for the hour.
The issue is that it converts both the hour 1 and 2 into 5 AM UTC and then continues with 7 AM UTC (skipping 6 AM).
This is how it is supposed to work, but in this use-case, we need the full day of data without it moving two hours into one hour in UTC.
0 - Sun, 01 Nov 2020 04:00:00 GMT
1 - Sun, 01 Nov 2020 05:00:00 GMT <<-
2 - Sun, 01 Nov 2020 07:00:00 GMT <<-
3 - Sun, 01 Nov 2020 08:00:00 GMT
4 - Sun, 01 Nov 2020 09:00:00 GMT
5 - Sun, 01 Nov 2020 10:00:00 GMT
Is there any way to achieve this?
https://jsfiddle.net/6peLc79u/1/
const date = "2020-11-01";
for (let i = 0; i < 24; i++) {
const utcString = moment
.tz(`${date} ${i}`, "YYYY-MM-DD H", "America/Toronto")
.toDate()
.toUTCString();
console.log(i, utcString);
document.write(`<li>${i} - ${utcString}</li>`)
}
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
<script type="text/javascript" src="https://momentjs.com/downloads/moment-timezone-with-data-10-year-range.min.js"></script>