Behind the scene: Basically I operate an app that heavily relies on time calculation. We store unixtime in the database according to the user’s timezone. Now to perform specific operations we need to convert that time from the native timezone to UTC. We recently transferred the application from another server It was working perfect but when we moved the application to a new server. The calculation that was written in Server Side Langauge was accurate but those calculations in which we wrote the logic in stored procedure output wrong date while converting it from unix_time to timestamp. Now you might question how do you know that output is wrong? Because I ran the same query over 2 different servers and the one that I am talking about returned wrong output.
The result from server having bug.
select convert_tz(from_unixtime(1585804204),'-04:00','+00:00')
----Output---
convert_tz(from_unixtime(1585804204),'-04:00','+00:00')
2020-04-02 11:10:04
The accurate result:
select convert_tz(from_unixtime(1585804204),'-04:00','+00:00')
----Output---
convert_tz(from_unixtime(1585804204),'-04:00','+00:00')
2020-04-02 05:10:04
If you put the same value of unixtime in the epoch converter (https://www.epochconverter.com/) you will get the value above mentioned select timezone America/New York.
I have also checked that clock of the host machine is fine. Please tell me how to resolve this error.
Click below to sign up and get $100 of credit to try our products over 60 days!