Where to get my time zone from?

php - how to get the server time zone

  • how do i get the srver time zone exept of the date("e") function i need somthing that will check the os time zone and not depends on the php ini and stuff like that... thanks!!! edit 1 i need this becouse i need to know the mysql time zone if i run a query for select global_time_zone i got the result "system" and i need a result like "amrica/new york"

  • Answer:

    If you're on *nix, call the system's date using http://www.php.net/manual/en/function.popen.php: popen("date +%Z");

dvdx at Stack Overflow Visit the source

Was this solution helpful to you?

Other answers

If you're using a Linux/Unix based hosting platform, you could use the output of the date command with the "alphabetic time zone abbreviation" formatter as such: $systemTimeZone = system('date +%Z'); However, it should be noted that you shouldn't necessarily rely on the system's timezone and that you should instead use http://www.php.net/manual/en/function.date-default-timezone-set.php (or the date.timezone php.ini setting) to set the required timezone.

middaparka

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.