Hướng dẫn php set timezone manila

How can I show the local date and time for Philippines?

Date: ". date('F j, Y g:i:a  ');
?>

Regent

5,1243 gold badges20 silver badges35 bronze badges

asked Sep 18, 2014 at 5:48

3

You shouldn't add space between and php

Date: ". date('F j, Y g:i:a  ');
?>

answered Sep 18, 2014 at 5:53

Hướng dẫn php set timezone manila

4

As @worldask already sad you shouldn't add space between those . 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.


      Current time: ".date("d-m-Y H:i:s");
?>

answered Sep 18, 2014 at 6:10

besciualexbesciualex

1,8271 gold badge14 silver badges20 bronze badges

3

Not the answer you're looking for? Browse other questions tagged php timezone or ask your own question.

Asia

Asia/Aden Asia/Almaty Asia/Amman Asia/Anadyr
Asia/Aqtau Asia/Aqtobe Asia/Ashgabat Asia/Atyrau
Asia/Baghdad Asia/Bahrain Asia/Baku Asia/Bangkok
Asia/Barnaul Asia/Beirut Asia/Bishkek Asia/Brunei
Asia/Chita Asia/Choibalsan Asia/Colombo Asia/Damascus
Asia/Dhaka Asia/Dili Asia/Dubai Asia/Dushanbe
Asia/Famagusta Asia/Gaza Asia/Hebron Asia/Ho_Chi_Minh
Asia/Hong_Kong Asia/Hovd Asia/Irkutsk Asia/Jakarta
Asia/Jayapura Asia/Jerusalem Asia/Kabul Asia/Kamchatka
Asia/Karachi Asia/Kathmandu Asia/Khandyga Asia/Kolkata
Asia/Krasnoyarsk Asia/Kuala_Lumpur Asia/Kuching Asia/Kuwait
Asia/Macau Asia/Magadan Asia/Makassar Asia/Manila
Asia/Muscat Asia/Nicosia Asia/Novokuznetsk Asia/Novosibirsk
Asia/Omsk Asia/Oral Asia/Phnom_Penh Asia/Pontianak
Asia/Pyongyang Asia/Qatar Asia/Qostanay Asia/Qyzylorda
Asia/Riyadh Asia/Sakhalin Asia/Samarkand Asia/Seoul
Asia/Shanghai Asia/Singapore Asia/Srednekolymsk Asia/Taipei
Asia/Tashkent Asia/Tbilisi Asia/Tehran Asia/Thimphu
Asia/Tokyo Asia/Tomsk Asia/Ulaanbaatar Asia/Urumqi
Asia/Ust-Nera Asia/Vientiane Asia/Vladivostok Asia/Yakutsk
Asia/Yangon Asia/Yekaterinburg Asia/Yerevan  

There are no user contributed notes for this page.

(PHP 5 >= 5.1.0, PHP 7, PHP 8)

date_default_timezone_set Sets the default timezone used by all date/time functions in a script

Description

date_default_timezone_set(string $timezoneId): bool

Instead of using this function to set the default timezone in your script, you can also use the INI setting date.timezone to set the default timezone.

Parameters

timezoneId

The timezone identifier, like UTC, Africa/Lagos, Asia/Hong_Kong, or Europe/Lisbon. The list of valid identifiers is available in the List of Supported Timezones.

Return Values

This function returns false if the timezoneId isn't valid, or true otherwise.

Examples

Example #1 Getting the default timezone

date_default_timezone_set('America/Los_Angeles');$script_tz date_default_timezone_get();

if (

strcmp($script_tzini_get('date.timezone'))){
    echo 
'Script timezone differs from ini-set timezone.';
} else {
    echo 
'Script timezone and ini-set timezone match.';
}
?>

See Also

  • date_default_timezone_get() - Gets the default timezone used by all date/time functions in a script
  • List of Supported Timezones

Pierre Gourlaouen

10 years ago

A simple method for conversation between two time zone.

$date = new DateTime("2012-07-05 16:43:21", new DateTimeZone('Europe/Paris')); date_default_timezone_set('America/New_York');

echo

date("Y-m-d h:iA", $date->format('U')); // 2012-07-05 10:43AM
?>