Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

99
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda