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

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