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

168
Visualizações
How to get absolute time using Moment JS and Unix timestamp

On server I use protobuf (google.protobuf.Int64Value start/end), convert DateTime value from database to timestamp(in milliseconds) with mapper and send to client.

Оn client i use moment to convert timestamps to start/end dates and display dates on screen

  1. When i test locally (the server and the client are on my machine, i.e. the timezone is the same, for example GMT + 3) - everything is displayed correctly. I am creating an event from 10 to 20 July:

In base:

start - 2022-07-10 00:00:00.0000000
end - 2022-07-20 23:59:59.9990000

Timestamps:

start - 1657400400000
end - 1658350799999

Moments on client:

start - Sun Jul 10 2022 00:00:00 GMT+0300
end - Wed Jul 20 2022 23:59:59 GMT+0300

Display in event list

7/10/22 - 7/20/22
  1. Problems with displaying dates start if I use a server located in a different time zone or, for example, I change the location in the browser (let it be Tokyo, GMT+9):

Moments on client:

start - Sun Jul 10 2022 06:00:00 GMT+0900
end - Thu Jul 21 2022 05:59:59 GMT+0900

Display in event list

7/10/22 - 7/21/22

How can this problem be solved? I should see the same event start/end time no matter what timezone the server or client is in.

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