Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

101
Visualizações
How can I explain this timezone behavior of Date?

For the JS Date object, ISO 8601 date strings that specify a time are treated as local (Note 2, here).

If we assume the locale for a machine is configured to be in England, and the current date in England is 23rd September 2022, the current local time zone (?) is UTC+0100 (British Summer Time).

If I supply a date without timezone that would in my locale ordinarily be in summertime (so in BST), then Date treats the string as BST (unsurprising).

If I supply a date without timezone that would, in my locale, ordinarily be outside of summertime (so in UTC), then Date treats the string as UTC (surprising, as UTC is not currently my local timezone).

new Date('2022-06-01T12:00:00') // Wed Jun 01 2022 12:00:00 GMT+0100 (British Summer Time)
new Date('2022-01-01T12:00:00') // Sat Jan 01 2022 12:00:00 GMT+0000 (Greenwich Mean Time) (! - my local timezone is BST, not GMT!)

How do I explain this? Is BST a time zone, or is it something else (eg. a mode of a timezone)?

almost 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

The timezone BST/British Summer Time does not exit on Jan 1st. The areas that use BST on the summer use GMT during the winter.

almost 4 years ago · Santiago Trujillo Relatório

0

For ISO 8601 date-times without a defined time zone, JavaScript does not assume the time zone to be the same as the time zone locally in effect, it assumes the local geographic location and then chooses the time zone that would be in effect at the specified wall-clock time in that location. Or something.

almost 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda