My client needs a system report his plugin running server details, It means I have lớn get hệ thống timezone. Working with Wordpress.Tried on this, But this not working on every server.

Bạn đang xem: How to detect user timezone in php

$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 hệ thống timezone? Any suggestions are greatly appreciated.


Highest score (default) Trending (recent votes count more) Date modified (newest first) Date created (oldest first)


Kindly refer following link

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


";}if (ini_get("date.timezone")) echo "date.timezone: " . Ini_get("date.timezone");?>this code will help you.

Xem thêm: Krvn Là Gì ? Kr Là Gì, Nghĩa Của Từ Kr


get some help from python. You can get vps timezone offset with python.

from time import gmtime, strftimeprint strftime("%z", gmtime())run the python code in php with exec

$tz_offset = exec("python");
Thanks for contributing an answer to Stack Overflow!

Please be sure to lớn answer the question. Provide details & share your research!

But avoid

Asking for help, clarification, or responding lớn other answers.Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.

Post Your Answer Discard

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy & cookie policy

Site thiết kế / hình ảnh sản phẩm © 2022 Stack Exchange Inc; user contributions licensed under CC BY-SA. Rev2022.11.11.43030

Your privacy

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device & disclose information in accordance with our Cookie Policy.