I used date("Y-m-d H:i:s"); to get current date time format but the result doesn’t match with my Windows system.
Example:
<?php
echo "Current date time: ".date("Y-m-d H:i:s")."<br />";
?>
The sample code displaying result:
Current date time: 2012-05-30 01:58:21
But my Windows system date time is 2012-05-30 09:56:04
I have tried using date_default_timezone_set('Asia/Singapore') function to get my region datetime and it’s work but I want it set default in my php.ini.
For example: (it’s work)
<?php
date_default_timezone_set('Asia/Singapore');
echo "Current date time: ".date("Y-m-d H:i:s")."<br />";
?>
I have also tried to set default value in php.ini that is date.timezone = "" changed to date.timezone = "Asia/Singapore" but doesn’t work.
I use Windows 7 Home Premium 64bit and php-5.3.13-Win32-VC9-x86. Does anyone know how to match between these value?
date_default_timezone_setwill supersede php default timezone setting, without needing to restart anything.But in your case it did not work. that’s weird. Try this as this is my last resort:
UPDATES:
Since what you need is a default php timezone and permanent solution without using
date_default_timezone_set, following the few simple steps below:phpinfo.phpwith one line content<?php echo phpinfo(); ?>Loaded Configuration File. Example valueC:\wamp\bin\apache\Apache2.2\bin\php.iniOpen the above
php.inifile with a notepad. Look for the[Date]and modify as below:datetime.php. Or you can also verify directly fromphpinfo.phpunder a h1 headerdateby making sure the default timezone is read as “Asia/Singapore” like below: