0

I have an issue with the date creation. The php server settings for timezone : by using the date_default_timezone_get() php function, refers to UTC whereas the MSQL query for timezone i.e @@system_time_zone is referring to MST. It is a shared server, so I will not be able to make changes in the my.conf file on the server.

I want the date to be in UTC format, How do I go about making changes on the mysql server so that the Now() function and CURRENT_TIMESTAMP returns date values wrt UTC.

user3230561
  • 445
  • 1
  • 10
  • 21

2 Answers2

1

If I understood you right you can try and set a timezone per session from client code

SET time_zone = timezone;

Depending on whether you have timezone info imported or not it may look like

SET time_zone = 'Etc/UTC';

or

SET time_zone = '+00:00';

Further reading:

peterm
  • 91,357
  • 15
  • 148
  • 157
  • Will this affect only the current database connection then? If there are multiple databases on the server I do not want this to affect any other db. – user3230561 Dec 15 '14 at 04:36
  • As stated it will affect only the session in which you connect to your database. It doesn't affect any other sessions. – peterm Dec 15 '14 at 04:41
0

Try fetching date from mysql query using UTC_TIMESTAMP() instead of NOW(), UTC_TIMESTAMP() will give you date in UTC.

Naved Munshi
  • 487
  • 1
  • 5
  • 17