HostGator.com » Support Portal

Can I change the server clock or time zone?

The server clock is set to Central Standard Time. You cannot change the time on a shared server's clock.

You can change the time zone being displayed with a PHP script. (Unfortunately, I cannot tell you where to put this code. You will need to consult with the program developer.) Here are two sample codes:

<?php
putenv("TZ=Europe/Amsterdam");
?>
<?php
date_default_timezone_set("America/Los_Angeles");
?>

You can set the timezone in .htaccess as well. (You can create a New File and name it ".htaccess", or you can edit the existing one. The .htaccess file belongs in /public_html/ - or a subdirectory if for a subdomain or addon domain). Add the line:

SetEnv TZ America/Indianapolis

Here is a list of supported timezones.


How do I change the timestamp on my emails?

Each webmail client has a timezone setting, which is set to the server clock by default.

SquirrelMail

  1. Go inside the webmail program and click Options at the top.
  2. Click the first link called Personal Information.
  3. Under Timezone Options, look for "Your current timezone:"
  4. Change the drop down to your time zone.
  5. Click the Submit button.

Horde

  1. Go inside the webmail program and click Options at the top.
  2. Click the second link called Locale and Time.
  3. Look for "Your current time zone:"
  4. Change the drop down to your time zone.
  5. Click the Save Options button.

RoundCube

  1. Go inside the webmail program and click Personal Settings at the top right.
  2. Under User Interface, look for "Time zone"
  3. Change the drop down to your time zone.
  4. Click the Save button.

Outlook 2007 - At any time, you can change the time zone in Outlook so that it matches your current geographic location. Please consult the Outlook Help menu for assistance with other versions.

  1. On the Tools menu, click Options.
  2. Click Calendar Options.
  3. Click Time Zone.
  4. Under Current time zone, type a name for the current time zone in the Label box.
  5. In the Time zone list, click the time zone that you want to use.
  6. If you want your computer clock to automatically adjust for daylight saving time (DST) changes, select the Adjust for daylight saving time check box. This option is available only in time zones that use daylight saving time (DST).
  7. Click OK and you are done.

Thunderbird - A Mozilla application has no clock of its own. It uses your system clock. Your system clock is controlled by your operating system settings. So, HostGator does not control this one. Read more...

MacMail - You can set your computer's date, time, and time zone so that the date and time appear correctly in the menu bar clock, Finder windows, Mail, and other applications. Read more...


Article Comments

sparkosis
Fantastic! This was the solution I've been looking for. I'm in the Pacific time zone and all times on my Joomla website were 2 hours too early! This fixed everything and it was so simple using cPanel.

ReeferGirl
I'm in Australia and have been trying to figure this out for AGES. Finally I found this thread. I couldn't get it working with the php code but the htaccess file did the trick. Thanks.

over9k
What about changing the timezone for mySQL?

HostGator
Same rules; you cannot change the time zone.

You can adjust the results using the PHP method described in this article.

Alternatively, you can also use PHP to adjust the hours using the date() function.

Josh Hanson
As a reseller, is there a location to specify the time zone so that it is inherited by my customers, but also giving them the opportunity to override it in their own .htaccess at the root?

Thanks,
Josh

HostGator
If you have root WHM (VPS and dedicated plans only), then you can go to Server Configuration >> Server Time and adjust the server clock by time zone.

However, this feature is not allowed for resellers, as they must share the server with other resellers.

The other option is to use your skeleton directory to store a default .htaccess file with the code already saved.

Brian Moreau
Just in case anyone was wondering I used this successfully on a shared server and simply inserted the code
putenv("TZ=Europe/London");
prior to calling any time functions such as
$date = (date('j-m-Y H:i:s'));

netang5
thanks for this! working fine now! cheers!

Epox
Great!

The .htacces works in cms systems. Requied to placejust in the root, and works well...

Staci
SUCCESS!

I put the following code in .htaccess file to reflect Eastern Standard Time on my site:

#Set server time zone
SetEnv TZ America/New_York


U.R
I can't seem to be able to get this working, I have tried .htaccess method, But I can't get the right time displayed in site builder. And I'm not really sure where to put .php

HostGator
SiteBuilder is not hosted on your account, so you cannot affect what SiteBuilder displays.

However, you should be able to affect what your website is showing (even if it was published by SiteBuilder).

If you still need help, please contact us via email, phone or live chat for assistance.

Stan
Hi there

Can anyone suggest the best practice for Drupal sites? Our automated notifications are being sent at the wrong time (CST rather than GMT).

Do I do the same and add to the .htaccess?

Many thanks :-)

Xavier Panson
date_default_timezone_set("America/Los_Angeles"); place that line just after you have done your include variables :)

Amit
$timezone = "Asia/Calcutta";
if(function_exists('date_default_timezone_set')) date_default_timezone_set($timezone);
mysql_query("SET SESSION time_zone = '+5:30'", $conn);

The above is what worked for me - called it in one of my top level includes and it took care of php as well as mysql. (please define $conn before using the above statement)

zia
thanks @amit..
you saved my time for mysql now()
thanks

amit kr
$timezone = "Asia/Calcutta";
if(function_exists('date_default_timezone_set')) date_default_timezone_set($timezone);
mysql_query("SET SESSION time_zone = '+5:30'", $conn);

Where these code have to apply... ??

in .htacess file ?

Deverick
Regarding @Amit's solution, the MySQL part is not working for me. In PHP setting time_zone and set session time_zone are both not changing the timestamp entered into the database
I have tried using these commands in the PHPMyAdmin interface and entering a row manually, but the result is still the same. Interestingly the command execute ok. FYI I am trying to set to UTC but UTC is not recognized in hostgator's MySQL so I am setting to:
SET SESSION time_zone = '-0:00'
This is a system setup issue, I sure hope the technicians fix this soon. I have logged a support call.

HostGator
Thank you for your comments. Just a quick reminder that the comments on this page are not monitored by technical support staff, and that for support issues, it is best to contact us by live chat, phone or email so we can assist you right away.

Although comments are not monitored by technical support staff, they are moderated and read by technical writers. Comments will need to be approved by a moderator before appearing.

Our technical writers do read the comments periodically for the purposes of updating the articles, and do appreciate your feedback, suggestions and corrections to the articles themselves, as well as any suggestions or tips for readers of this article. However, support questions posted here are not guaranteed to be replied to in a timely manner or at all. For support issues, it is best to contact our support staff instead by live chat, email or phone.



Your comments help us keep the knowledge base updated. This is not a medium for support. If you have questions or need help, please contact us via email, phone or live chat for fast assistance.

Post Comment