How can I show the local date and time for Philippines?
<? php
date_default_timezone_set('Asia/Manila');
echo "<span style='color:red;font-weight:bold;'>Date: </span>". date('F j, Y g:i:a ');
?>
You shouldn't add space between <?
and php
<?php
date_default_timezone_set('Asia/Manila');
echo "<span style='color:red;font-weight:bold;'>Date: </span>". date('F j, Y g:i:a ');
?>
date_default_timezone_set('Asia/Manila');
has already set your timezone correctly
As @worldask already sad you shouldn't add space between those <? php
. The rest of the code is good.
The reason why you don't get the date you want, is that the server's time is different than you think it is. When the PHP engine adds 8 hours to his system date it gives you a good result. In order to check which is the current hour and debug your problem use the following code, then fix the system's date.
<?php
echo "Current timezone: ".date_default_timezone_get()."</ br>
Current time: ".date("d-m-Y H:i:s");
?>
<?php date_default_timezone_set('Asia/Manila'); echo "<span style='color:red;font-weight:bold;'>Date: </span>". date('F j, Y g:i:a '); ?>