My client needs a system report his plugin running server details, It means I have to get SERVER timezone. Working with Wordpress. Tried on this, But this not working on every server.
$date = new DateTime(); $date->setTimezone(new DateTimeZone(ini_get('date.timezone')));
This gives me a fatal error on some servers, Got any common function to get server timezone?
Any suggestions are greatly appreciated.
Try this:
$date = new DateTime(); $timeZone = $date->getTimezone(); echo $timeZone->getName();
Kindly refer following link https://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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With