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

266
Visualizações
Check midnight in a specific time zone node js

I have user's timezone, let say

timeZone: 'America/New_York'

I want to perform some tasks at midnight according to the user's timezone. How can I check if the midnight has arrived in this timezone?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Last midnight in a specific timezone:

new Date(new Date().toLocaleDateString('en-US', { timeZone: 'America/New_York', timeZoneName: 'short' } ))

Database friendly UTC time of last midnight in a specific timezone

new Date(new Date().toLocaleDateString('en-US', { timeZone: 'America/New_York', timeZoneName: 'short' } )).toISOString()

Note: understand 'last midnight' as today-in-zone midnight

Explanation:

  • new Date() is current time (whatever the zone - time object)

  • .toLocaleDateString('en-US', { timeZone: 'America/New_York', timeZoneName: 'short' } ) displays the current date (no time, so midnight) in the specified zone (string of time with zone ref)

  • new Date(<above midnight time in zone>) parse the midnight time in zone and display corresponding current timezone time (time object)

  • .toISOString() display above at UTC reference (ISO datetime string)

about 4 years ago · Juan Pablo Isaza 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