Singapore CMS Web Design

Gary Consulting Group - Singapore CMS Web Design

Timely Support and Clarity in your journey to harness the power of the internet
+1 415 300-0019
How to the Default TimeZone in Wordpress

Our team was doing some customization work on the Wordpress Content Management System for today. The customization required we implement a time dependant feature. Apparently for some strange reasons, the date('Y-m-d G:i:s') function of the PHP installation on our local testing server was not outputting time in the correct time zone.

Our local time was 2011 Feb 2nd, 1300hrs. The output was 2011 Feb 2nd, 0500hrs

To resolve this issue, we first went to examine the settings in our PHP.ini configuration file. There was this line of configuration in the PHP.ini file that looked like this

;date.timezone =

It meant that the time zone was not set at the PHP.ini level. Since we were here, I thought for future's sake we might as well set it anyways. Thus we did. The new setting is date.timezone =Asia/Singapore. This is the logical choice considering the fact we are in Singapore.

To test that our settings are detected properly we went and wrote and independent script which looked like the below

<?php echo date("Y-m-d G:i:s"); ?>

The time got displayed correctly when we went fetched the output. Thereafter we wrote the sames script once more, but this time as part of the Wordpress Content Management System. Strangely, though the output was still 8 hours behind. We suspected there might be a built in time zone feature on wordpress. Thus we dug once more into the codes. We did a syntax search through the entire Wordpress code base and Eureka we found the culprit

At line 32 of this file /wp-settings is this line of code date_default_timezone_set( 'UTC' );. This obviously was setting the default timezone for our Wordpress Content Management System to US time. Thus we changed the code to this date_default_timezone_set( 'Asia/Singapore' ); instead.

Once done, we were done, we went ahead and tested our little script. It was still coming out as 8 hours behind Singapore time. Not to give up we went ahead and dug further into the features of Wordpress. We realized in the general tab of the admin console, there is this place where we could set the time zone we want our contents to be displayed in. Thus we set it to Asia/Singapore as well.

Now that we have synchronized the time zone between our local testing server, our PHP installation, the default time zone in our Wordpress Content Management System as well as the time zone displayed by our Wordpress Content Management System all is working well.

See the video below if you need proper graphical illustration

If you have some doubts after reading this article
contact us
we will be glad to clarify them
Thursday, 22nd Jun 2017
Content Management System powered by Gary from