Getting wrong timezone time from the TIMESTAMP in mysql

Viewed 280

In my application, I am using MySQL(version: 5.6.10) and storing the time as TIMESTAMP. When I try to retrieve the time, I am getting the wrong time.

My Timezone is +5:30. When I store timestamp, it is storing with +00:00 timezone. When I retrieve the time, the time is coming by subtracting ie. -05:30 instead of +05:30.

Let me add an example

If I store a time using NOW() at 2020-11-02 12:00:00, it is stored as 2020-11-02 06:30:00. But, when I retrieve the data, it is coming as 2020-11-02 01:00:00 again by subtracting -05:30. I don't understand why this is happening.

Please help me solve this.

Thank you...

1 Answers

you need to change timezone in php.ini file else set timezone in default-time-zone='+00:00' my.cnf, If you don't want to changeanything at server end then run query

SELECT UNIX_TIMESTAMP(column_name) FROM tablename

Related