Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

271
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda