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

109
Views
mongoose overrides dates timezone

I'm using mongoose and no matter what I tried, it overrides the stored dates' timezone.

I tried all of these defaults (one by one of course):

const ModelSchema = new Schema({
  date: {
    type: Date,
    default: new Date().toLocaleString('en-US', { timeZone: 'Asia/Jerusalem' }),
    default: moment.tz(Date.now(), 'Asia/Jerusalem'),
    default: Date(moment.tz(Date.now(), 'Asia/Jerusalem')),
  }
})

it seems mongoose runs new Date on whatever value I put there, because if I run this directly in node:

> Date(moment.tz(Date.now(), 'Asia/Jerusalem'))
'Sun Oct 03 2021 06:28:39 GMT+0300 (Israel Daylight Time)'
> new Date(moment.tz(Date.now(), 'Asia/Jerusalem'))
2021-10-03T03:28:42.217Z

what am I missing here?

I currently tested it only locally on my laptop

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