Web development and examples of PHP, jQuery, HTML5, WordPress, MySQL & AMP

PHP date_default_timezone_get(): Get default time zone UTC

When we are working with dates in PHP we always have to consider if the time zone of the system is correct. To obtain this information we have the function of PHP date_default_timezone_get() that will return a string with this zone.

Syntax of PHP date_default_timezone_get()

This is the syntax of the function extracted from the official website:

Example of PHP date_default_timezone_get()

Let’s see how the following code represents the time zone in the PHP example of PHP date_default_timezone_get().

Running this script on this server returns the following code:

Time zones supported by PHP date_default_timezone_get()

The time zones that we have in PHP are those that appear in this link.

PHP code to return time difference

The following code is NOT mine, but it will be very useful, via php.net, you can see it working the same demo as before but in the example 2:

PHP functions with dates

Cookie Policy

This website uses cookies to provide you with the best user experience. If you continue to browsing you are consenting to the acceptance of these cookies and acceptance of our cookie policy, click the link for more information.

Aviso de cookies