Abhilash Khangar
Abhilash Khangar

Reputation: 11

Date from server to client getting changed

I have server using Indian timezone and client is on Chicago timezone.I'm sending data from server as a JSON. Date coming from server is 25-07-2019 (1563993000000 as JSON string). When i'm converting this date in javascript using "new Date(1563993000000);", it becomes "24-07-2019". How to convert server date to client side using server timezone? I'm working on Angular.

Upvotes: 0

Views: 983

Answers (1)

BLACKMAMBA
BLACKMAMBA

Reputation: 725

The date coming from the server is incorrect, according to the timestamp provided the date should be

1563993000 converts to Wednesday July 24, 2019 13:30:00 (pm) in time zone America/Chicago (CDT)

you can convert the date to correct time stamp by specifying the timezone

new Date(1563993000000).toLocaleString("en-US", {timeZone: "America/Chicago"})

https://www.epochconverter.com/timezones?q=1563993000000&tz=America%2FChicago

Upvotes: 1

Related Questions