Comments - convert_unixtime outputs wrong date time

1 month, 4 weeks ago Ian Gilfillan

FROM_UNIXTIME expresses the value in the current time zone. So your servers most likely have different time zone values:

SET time_zone = '+2:00';

select convert_tz(from_unixtime(1585804204),'-04:00','+00:00');
+---------------------------------------------------------+
| convert_tz(from_unixtime(1585804204),'-04:00','+00:00') |
+---------------------------------------------------------+
| 2020-04-02 11:10:04                                     |
+---------------------------------------------------------+

SET time_zone = '+4:00';
select convert_tz(from_unixtime(1585804204),'-04:00','+00:00');
+---------------------------------------------------------+
| convert_tz(from_unixtime(1585804204),'-04:00','+00:00') |
+---------------------------------------------------------+
| 2020-04-02 13:10:04                                     |
+---------------------------------------------------------+
 
1 month, 4 weeks ago Hasnain Haider

Is there is any way to set the default timezone for a user in the system.

 
1 month, 4 weeks ago Ian Gilfillan

I don't think so, but you can set time zone by session.

 
1 month, 4 weeks ago Hasnain Haider

Hey Thank, you very much. I understand the concept now.

 
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.