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

266
Views
Converting a moment to JS Date in ISO format

I have been trying somewhat unsucessfully to convert a date I have in Moment format to a JS Date object that is in the ISO 8601 format. The API library I am using needs the date to be a JS Date object but needs to format to be 8601. When I try this now my moment is the correct time in 24 hour format

Moment {_isAMomentObject: true, _i: '2021-10-07T15:00:00', _f: 'YYYY-MM-DDTHH:mm:ss', _isUTC: true, _pf: {…}, …}
_a: (7) [2021, 9, 7, 15, 0, 0, 0]
_d: Thu Oct 07 2021 11:00:00 GMT-0400 (Eastern Daylight Time) {}
_f: "YYYY-MM-DDTHH:mm:ss"
_i: "2021-10-07T15:00:00"
_isAMomentObject: true
_isUTC: true

but when I convert to a date it tries to fix the timezone so its always off by 4 hours so like momentVar.toDate() =

Thu Oct 07 2021 11:00:00 GMT-0400 (Eastern Daylight Time)

the moment gets set initially through url param:

eventTime=2021-10-07T15:00:00

what is the right get a JS Date object in an ISO 8601 format but not as a string with the .toISOstring() method

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!