Jump to content

Recommended Posts

Posted

Hi,

Does anyone know of a way to change the timezone in CPanel (or in code) so that I can have NOW() return the time in the timezone of AEST instead of PST, as my users are all from Australia and none are from America.

  • 3 weeks later...
Posted

This topic is a little old but I think I might be able to add a little bit more information about changing timezones.

 

PHP

Here's an example on how to get and change timezones. Changing the timezone affects functions related to time and date:

<?php
echo date_default_timezone_get(); // Get default timezone used by date/time functions
echo date('Y-m-d H:i:s'); // Get current time

date_default_timezone_set("UTC"); // Change default timezone to UTC
echo date_default_timezone_get(); // Get default timezone used by date/time functions
echo date('Y-m-d H:i:s'); // Get current time

Will output:

America/Los_Angeles
2015-05-01 06:14:49
UTC
2015-05-01 13:14:49

 

SQL

Now, you were probably referring to the NOW() function in SQL.

 

Get timezone used by server:

SELECT @@system_time_zone;

Will output:

PDT

 

Change timezone used by server (for current session):

SET time_zone = '+00:00'; -- Change timezone to UTC
SELECT NOW();

Will output:

2015-05-01 13:16:28

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...