PHP Function Date_Default_Timezone_Get
Dealing with timezones is a vital aspect of working with date and time functions in any web application. Setting the default timezone correctly ensures that your application accurately represents dates and times based on the user's location. The default timezone should be set as early as possible in your script, preferably at the very beginning, and should be a valid timezone string (such as "America/New_York" or "Europe/Rome") - for more information see PHP documentation.
The php function date_default_timezone_get is used to get the default time zone that is used by all the date and time functions in your script. It accepts one argument, which is the default time zone. If this argument is not set, the function will return a default value of UTC. It also returns False if the timezone identifier is invalid or True if it has been set.
This function is available starting with PHP Version 5.1.0 and works on all later versions of PHP. It was previously possible to read the default timezone by reading the TZ environment variable, but this is now deprecated and the php function date_default_timezone_get should be used instead.
To demonstrate how this function is used, we have created a simple example script. The first line of the script sets the default timezone to 'UTC' and then calls the date_default_timezone_get function two more times, once before setting the timezone and again after it has been set. The result is shown below.