I'm new to php. I was able to get the time but the problem is it's in different time zone. What I want is to get the time in my timezone. Here's my code:
<?php
date_default_timezone_set('UTC+8');
$mydate=date('h:i A');
?>
The codes above gives me the wrong time, my timezone is UTC+8. Example my time is 9:00PM, but the codes above returns 1:00PM. How could I fix this? Any help would be so much appreciated.
UPDATE: I got it working now (thanks to @enenen). My new code that returns the correct timezone in my area:
<?php
date_default_timezone_set('Asia/Manila');
$mydate=date('h:i A');
?>
I think you are looking for
date_default_timezone_set('Etc/GMT+8');
or
date_default_timezone_set('Asia/Manila');
Timezone ID 'UTC+8
' is invalid. It is a notice from PHP
engine, if your error reporting is excludes notices, this is the reason not to see it. You shoud use something like 'Asia/Manila
'. See documentation here.
if you want a list of available time zones and how to set them follow this link, easy to read and doesn't take long :P
date_default_timezone_set('Etc/GMT+8'); works for me i'mm from the Philippines and Asia/Manila doesn't work