Get server timezone In PHP Get server timezone In PHP wordpress wordpress

Get server timezone In PHP


Try this:

$date = new DateTime();$timeZone = $date->getTimezone();echo $timeZone->getName();


Kindly refer following linkhttps://www.w3schools.com/php/func_date_default_timezone_get.asp

    <?php      echo date_default_timezone_get();    ?> 

The date_default_timezone_get() function returns the default timezone used by all date/time functions in the script.


<?php 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');}?>

this code will help you.