PHP date_timezone_set() Function
In this chapter you will learn:
- Definition for PHP date_timezone_set() Function
- Syntax for PHP date_timezone_set() Function
- Parameter for PHP date_timezone_set() Function
- Return for PHP date_timezone_set() Function
- Example - Set the timezone for the DateTime object
Definition
The date_timezone_set() function sets the time zone for the DateTime object.
Syntax
PHP date_timezone_set() Function has the following syntax.
date_timezone_set(object,timezone);
Parameter
PHP date_timezone_set() Function has the following syntax.
Parameter | Is Required | Description |
---|---|---|
object | Required. | DateTime object returned by date_create(). |
timezone | Required. | DateTimeZone object that represents the desired time zone. |
Return
PHP date_timezone_set() Function returns the DateTime object for method chaining. FALSE on failure.
Example
Set the timezone for the DateTime object:
<?php
$date=date_create("2013-05-25",timezone_open("Indian/Kerguelen"));
echo date_format($date,"Y-m-d H:i:sP");
?>
The code above generates the following result.
Next chapter...
What you will learn in the next chapter:
- Definition for PHP getdate() Function
- Syntax for PHP getdate() Function
- Parameter for PHP getdate() Function
- Return value for PHP getdate() Function
- Example - Return date/time information of the current local date/time
Home » PHP Tutorial » PHP Date Functions