PHP date_default_timezone_set() Function
In this chapter you will learn:
- Definition for PHP date_default_timezone_set() Function
- Syntax for PHP date_default_timezone_set() Function
- Parameter for PHP date_default_timezone_set() Function
- Return for PHP date_default_timezone_set() Function
- Example - Set the default timezone
Definition
The date_default_timezone_set() function sets the default timezone used by date/time functions.
Syntax
PHP date_default_timezone_set() Function has the following syntax.
date_default_timezone_set(timezone);
Parameter
- timezone - Required. Timezone to use, like "UTC" or "Europe/Paris".
Return
PHP date_default_timezone_set() Function returns FALSE if the timezone is not valid. TRUE otherwise.
Example
Set the default timezone:
<?php
date_default_timezone_set("Asia/Bangkok");
echo date_default_timezone_get();
?>
The code above generates the following result.
Next chapter...
What you will learn in the next chapter:
- Definition for PHP date_diff() Function
- Syntax for PHP date_diff() Function
- Parameter for PHP date_diff() Function
- Return value from PHP date_diff() Function
- Example - calculate the difference between two dates
Home » PHP Tutorial » PHP Date Functions