0

When i am running a query with NOW(), it gives me incorrect time (Actual Time+4 Hours).

"SELECT NOW() AS current_time ";

The above is the simple query.

  • 5
    Its because your timezone will be different for Mysql or in php.ini file. If its the live server then check the default timezone of your server. – Himanshu Upadhyay Apr 30 '18 at 13:04
  • The code is working in Localhost, i will contact my server providers –  Apr 30 '18 at 13:07
  • Possible duplicate of [MySQL timezone change?](https://stackoverflow.com/questions/3451847/mysql-timezone-change) – Meloman Apr 30 '18 at 13:09
  • 1
    Check `SELECT @@session.time_zone` and `SELECT TIMEDIFF(NOW(), UTC_TIMESTAMP)`. PHP's timezone and MySQL's session timezone can be changed at runtime, the provider may or may not have anything to do with it. – Vatev Apr 30 '18 at 13:09
  • i tried SELECT TIMEDIFF(NOW(), UTC_TIMESTAMP) giving me the below output -04:00:00 –  Apr 30 '18 at 13:12
  • any idea about the issue? –  Apr 30 '18 at 13:20
  • 1
    you have to check your server timezone, if you want your timezone time then you have to change timezone of server based on your location – Jenish Apr 30 '18 at 13:31

0 Answers0