Want to get server timezone in PHP? Use the following example code to get server timezone using PHP.
Example #1 How to get server timezone in PHP.
1 2 3 | $date = new DateTime(); $timeZone = $date->getTimezone(); echo $timeZone->getName(); |
Example #2 How to get server timezone in PHP.
1 2 3 4 5 6 7 8 9 | date_default_timezone_set(); if (date_default_timezone_get()) { echo 'date_default_timezone_set: ' . date_default_timezone_get() . '<br />'; } if (ini_get('date.timezone')) { echo 'date.timezone: ' . ini_get('date.timezone'); } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.