Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

265
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!