In this article, you will learn how to set a new timezone. date_default_timezone_set() PHP function set the new default timezone used by all the Date and Time functions in the current script.
What is the syntax of date_default_timezone_set() function in PHP?
date_default_timezone_set(timezone)
Parameter | Details |
---|---|
timezone | Timezone to make it the default – Required You can refer to the list of all available timezones in PHP at http://www.php.net/manual/en/timezones.php |
Examples of the date_default_timezone_set() function
Example 1. In the following example, we simply set the new default timezone to Asia.
<?php
date_default_timezone_set("Asia/Bangkok");
echo date_default_timezone_get();
?