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

97
Views
getting time zone name from offset in moment.tz

I have a api which needs to store a utc+timestamp in mongodb. I am trying to save the value in mongodb which is saving in UTC time. While retreiving i am trying to send the current time using the below code

return moment.tz("2022-02-04T08:19:38Z","Asia/Seoul").format()

The above code is working fine. Now i have a use case as the input format will be

2022-02-04T08:19:38Z+09:00 

I need to get the timeZone from the offset above likeif i pass +0900 i need output as "Asia/Seoul",Any idea as how can I proceed forward? Kindly help

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

String 2022-02-04T08:19:38Z+09:00 is not valid. Z indicates UTC time while +09:00 indicates UTC offest, i.e. you provide a timestamp with two (different) time zones.

As it is ambiguous I cannot propose a solution. Is 2022-02-04T08:19:38 intended to be UTC or Seoul time?

This one would work:

moment("2022-02-04T08:19:38+09:00").format()

MongoDB stores date values as UTC time - always and only! If you need to preserver the input time zone, then you have to store it separately in an extra field.

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!