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

167
Views
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
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!