0

Different Browsers are returning different dates for the same intl.DateTimeFormat function.

Brazil are not following Daylight saving this year https://www.timeanddate.com/time/change/brazil?year=2020#targetText=Daylight%20Saving%20Time%20(DST)%20Not,was%20on%20February%2016%2C%202019

And Intl.DateTimeFormat appears to return the incorrect time (the example date below is in November 2019)

Example on JSBin: https://jsbin.com/waxekocaqa/edit?html,js,output

const timestamp = new Date('2019-11-07T20:00:00Z');

const londonDf = new Intl.DateTimeFormat('en', {
  hour: 'numeric',
  minute: 'numeric',
  timeZone: 'Europe/London'
});

const saoPauloDf = new Intl.DateTimeFormat('en', {
  hour: 'numeric',
  minute: 'numeric',
  timeZone: 'America/Sao_Paulo'
});

console.log(londonDf.format(timestamp)); // 8:00 pm
console.log(saoPauloDf.format(timestamp)); // 6:00 pm (should be 5:00 pm)

The expected result for saoPauloDf should be 5:00 pm, but please let me know if i missing something obvious.

Also, Safari shows the correct times, but Chrome does not

10
  • In which implementation? Safari shows 5 pm, Chrome 6 pm, Firefox 5 pm, Opera 6 pm. You'll have to test every implementation to determine which are correct and which aren't.
    – RobG
    Oct 23, 2019 at 12:31
  • 5pm is the correct time when using a date/time in November Oct 23, 2019 at 12:35
  • Run Windows Update?
    – Salman A
    Oct 23, 2019 at 12:35
  • 1
    @SalmanA—implementations rely on the OS for host timezone settings, not the entire history of global timezone offsets plus representative locations such as might be held by the IANA Timezone Database. If the OS had such information, and implementations had access to it, why would two browsers on the same system report differences as indicated in my first comment?
    – RobG
    Oct 23, 2019 at 13:01
  • 1
    @salmana - Yes, and I'm on a mac Oct 23, 2019 at 15:18

0

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.