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

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

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 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