InMotion Hosting Support Center

If you notice the correct time is not displaying in your PHP scripts the likely culprit is that the hosting server is in a different timezone. You can easily resolve this by adding a line of code to your php.ini file. The location you set in the code will determine the time to display in your PHP scripts.

How to Set the PHP Timezone:

  1. Open your php.ini file with the File Manager in cPanel
  2. Add the following line of code to top of your php.ini file
    date.timezone = "US/Central"
  3. Replace "US/Central" with the timezone from here that corresponds to the time you want to display.
  4. Once you have entered the desired timezone, click the Save Changes button to save the file.
  5. Now, you can check your phpinfo.php page to verify the change took place.
    Before:After:
    timezone_3 timezone_4

If you need further assistance please feel free to ask a question on our support center.

Support Center Login


Social Media Login

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question
n/a Points
2014-05-13 12:17 am

Be sure after you have done this to stop apache and restart apache... Well shut down the web server and restart it again so php will pick up the timezone change.

Staff
13,793 Points
2014-05-13 9:52 am
Hello Anthony,

Thank you for your comment. But, it is not necessary to restart the server when changing the timezone.

You will also not have the ability to do so in a shared servers setting, since it will bring everyone's site down.

If you have any further questions, feel free to post them below.
Thank you,

-John-Paul
n/a Points
2014-08-12 1:35 am
Uploading videos would help us set the timezone for PHP in the php.ini
Staff
13,793 Points
2014-08-18 9:58 am
Hello aravindhan.m,

Thank you for your suggestion. I will review this article and determine if a video would help people set the timezone for PHP in the php.ini.

If you have any further questions, feel free to post them below.
Thank you,

-John-Paul
n/a Points
2015-03-16 12:48 pm

I would like to know how to change time zone in shared sever please. Thanks 

Staff
13,793 Points
2015-03-16 1:59 pm
Hello Andy,

Thank you for contacting us. The above guide explains just that. Were you able to follow the above guide?

Did you have trouble with a certain step?

Thank you,
John-Paul
n/a Points
2015-03-16 8:00 pm

I did tried it and it had changed in my php.ini file but whenever I submit the data to my database the time still wasn't changed in my database. thanks a lot for your time.

n/a Points
2015-03-17 12:42 am

If the times that the data is logged in your DB are according to GMT (example being) then you can do a fairly simple convert according to what UTC offset by adding or subtracting an hour (eg. 3600 seconds per hour if logged using a Unix Timestamp).

As for further entries in the DB, I would recommend to use the same method as has been used to this point unless an upgrade is in order.  In which case, change relevant data points to match as you desire and and for all previous data, use a conversion script.

Some simple logic can be used for this test to create a converter.

if($db_time < $new_stamp) {

   // add the lines as needed depending of the UTC offset

}

n/a Points
2015-03-16 7:36 pm

If you are using any form of PHP templating, this should still work if placed in the top of your template page (or in the top of each page that needs this): ini_set("date.timezone", "America/Los_Angeles");

This will make sure it stays as your script needs it and it is just a change for your script(s) only.

n/a Points
2014-08-17 4:45 am

How to find php.ini file in the File Manager?? I couldn't find it

Staff
13,793 Points
2014-08-18 10:07 am
Hello Silvi,

Thank you for your question. Since I could not locate your account with us, here is some background information on the php.ini file. This is from our guide on How to update your local php settings.

Only users running on a server with PHP loaded as a "CGI module" will have a php.ini file. The php.ini file by default will be located at public_html/php.ini. If you do not see a file named php.ini in your public_html, please contact our Support Department and request that we create one for you.

If you have any further questions, feel free to post them below.
Thank you,

-John-Paul
n/a Points
2014-08-28 2:19 pm

This would be another way to use / set this >

<?php

if(ini_get("date.timezone")!=="America/Los_Angeles") {

if(ini_set("date.timezone", "America/Los_Angeles")===FALSE) {

echo "Unable to set timezone."; // You could send to another var for display elsewhere too.

}

}

?>

 

That is if you where using a PHP templating method by which you used the same template page across your entire site.  This would go right near the top to be sure to check the setting and change it to the timezone desired.

 

This page may be of help to anyone in the Americas too > http://php.net/manual/en/timezones.america.php

n/a Points
2015-03-01 3:25 pm
it contains all needed information
n/a Points
2015-03-11 5:24 pm

thank your help.

I use this key in opencart change timezone is succussed.

n/a Points
2015-03-28 12:33 pm

I just moved my accounts to IM and am testing.  I went to a Members Only login page and got two errors re: php that I am not getting on the old server.  I checked the version of php and set it to the same 5.3 that it was using before. 

Warning: session_start() [function.session-start]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Los_Angeles' for 'PDT/-7.0/DST' instead in /home/uscold/public_html/mo/membersOnly.php on line 6 Warning: session_start() [function.session-start]: open(/tmp/sess_e079720753ff740ed0a801cea301a3d3, O_RDWR) failed: Permission denied (13) in /home/uscold/public_html/mo/membersOnly.php on line 6

 

I tried adding the line in php.ini for the timezone as instructed on this page but am still getting these errors.  Can you point me to a solution?  Thanks.  (I'm not knowledgeable in php beyond very simple basics)

Staff
25,359 Points
2015-03-30 9:43 am
Hello hermit,

You will also want to make sure your php.ini file is recursive. That should solve the issue for you.

Kindest Regards,
Scott M
n/a Points
2015-04-03 7:12 pm

I would like to know how to go back automactically to home page 3 seconds after submitting the data. I'd tried with header but it goes back and forth. Please guide me through that. Thanks a lot for your time.

Staff
21,814 Points
2015-04-03 8:35 pm
Hello Andy,

Unfortunately, providing programming support is beyond the scope of our support. Please consult with a developer or forum that helps with programming a solution to meet your needs.

Regards,
Arnel C.

Post a Comment

Name:
Email Address:
Phone Number:
Comment:
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

18 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!