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


PHP date_default_timezone_set(): Set default time zone UTC

New post to review the function of PHP date_default_timezone_set() that sets the default time zone.

This PHP function sets the default time zone in all of the date functions we use in our PHP script. Let’s see what the date_default_timezone_set() nomenclature looks like.

Related function:

Syntax of date_default_timezone_set()

In the code we can see that the function only needs to be passed a string with the time zone, in my case for example it would pass ‘Europe/Berlin‘.

Here we can see a list of the supported time zones.

Example of date_default_timezone_set()

We will see in the following lines a simple example where we will establish by default ‘Australia/Melbourne’ and we will ask the system the default time zone (it would have to return the same):

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.

ACEPTAR
Aviso de cookies