A question I’ve seen come up from time to time is how do I set the correct timezone in Xampp!
Xampp is my tool of choice when working with breaking WordPress. It’s incredibly intuitive and easy to install. You don’t even have to be a developer to find it useful. I often recommend it as a way of testing new functionality (such as plugins) prior to messing with your live blog. You can even use it to maintain a local copy of your live blog.
During the installation process you will be presented with various dialogue boxes. One such dialogue states that the timezone values in both php.ini and my.ini have been set to “America/Chicago” and that you should change them if they are not correct. The problem is you’re not told where you can easily find those files.
Before you do anything you’ll need the timezone information applicable to you. Head over to http://us2.php.net/manual/en/timezones.php where you will find a list of supported timezones divided by various geographic regions. I chose “America”. Then, you will be presented with a list of timezones under the heading “America”. I chose “America/Winnipeg” – select the one applicable to you.
Armed with that tidbit of information we can now make the necessary changes.
First, navigate to C:\xampp\php\php.ini and open the file in a plain text editor such as Notepad. Look for the following …
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = "America/Chicago"
… and change “America/Chicago” to the proper value. In my case it is “America/Winnipeg”. Save the file and restart Apache (if it is running) in order for the change to take effect.
Next, navigate to C:\xampp\mysql\bin\my.ini and open the file in a plain text editor such as Notepad. Look for the following …
default-time-zone = "America/Chicago"
… and again change the value to the one applicable to you. Save the file and restart MySQL (if it is running) in order for the change to take effect.
That’s it!

thanks, that worked
You’re welcome Roa.
Thanks! This helped out in a project I’m working on.
Hi Catzie. Glad you found the info useful.
Hi Len,
I got the php.ini file changed with no problem, but when I went to my.ini I didn’t find default_time_zone in there anywhere. Am I missing something?
Thank you!
Hi Jerry.
Good question. This tut was written for previous versions of Xampp. I just took a look at that file using version 1.7.4 and that option is indeed missing.
I submitted a question to the fine folks over at Apache Friends and when I get an answer I’ll post the reply here.
Hi Jerry.
I have received a reply from the wonderful people over at Apache Friends. You can manually add the line in question to the my.ini file.
You can view the details at the following thread.
http://www.apachefriends.org/f/viewtopic.php?f=16&t=47656&p=182647#p182638
Thank you!
You’re welcome.
First of all, thanks for your post. It helped me.
I still have a question.
I noticed at [Date] section of php.ini file there are other settings :
- http://php.net/date.default-latitude ,
- http://php.net/date.default-longitude ,
- http://php.net/date.sunrise-zenith , and
- http://php.net/date.sunset-zenith .
Its names indicates for what they are related but…
Must have I worry with them?
Hi M. Miranda.
I wouldn’t worry about those. They are simply settings that allow you to extract the date/time of PHP scripts running on the server and to format them in a variety of ways. These are PHP functions that have been available since PHP 5. I wouldn’t worry about them.
If you’re interested, you can read more about them at the links below:
• http://www.tutorialspoint.com/php/php_date_time_functions.htm
• http://www.w3schools.com/php/php_ref_date.asp
thanks sir !! it worked for me
You’re most welcome.
Thanks for getting me on the right track. I don’t have a my.ini in the mysql\bin directory.
(xampp 1.7.0, Apache 2.2.11, MySQL 5.1.30 and php 5.2.8)
Initially, I made the change in \xampp\php\php.ini and php5.ini, but that didn’t work.
However, I did find another php.ini in \xampp\apache\bin\php.ini … made the change, now everything is working as it should.
You’re welcome Kevin.
ok … was working ok … but not now.
The situation: I am running php script that displays a time that a data file is updated. Originally, the script was displaying UTC, until I made changes (as described above) to all instances of php.ini and php5.ini I could find.
The script worked fine, giving local time readings … until I integrated the script into WordPress.
The script has two parts .. an admin part (which is still outside WordPress), and a user part (now integrated inside a WordPress theme). The Admin script displays the correct local time that the file was updated, while the user script displays UTC time, leading me to believe that the whole problem lies within WordPress somewhere.
I found functions.php inside WordPress … but aren’t game enough to start fiddling with that as yet.
Any ideas of the best way to fix this time problem inside wordpress?
sorry for another post …
This at the very top of functions.php inside WordPress fixes the problem, but who knows what other problems it might create …
date_default_timezone_set(“Australia/Adelaide”);
This is not an efficient fix. Every time wordpress updates, then the file will have to be edited.
I’m not sure what the adverse effect of doing that would be (if any) but an even better method would be to add it to the
wp-config.phpfile. Be sure to use single quotes as such …date_default_timezone_set('Australia/Adelaide');More info from the WordPress support forum in this reply from Otto.
very helpful, thanks!
Glad you found it useful Tim.
i made change in two files php.ini and my.ini and restart two service
but when i run my code
date_default_timezone_set (‘Africa/Cairo’);
$date = date(‘h:i:s’, time());
echo $date;
still get system time
Hi Allaa
Have you followed the instructions in this thread …
http://www.apachefriends.org/f/viewtopic.php?f=16&t=47656&p=182647#p182638