PHP | date_timezone_set() Function Last Updated : 17 Sep, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report The date_timezone_set() function is an inbuilt function in PHP which is used to sets the time zone for the DateTime object. This function returns the DateTime object or False on failure. Syntax: Procedural style: date_timezone_set( $object, $timezone ) Object oriented style: DateTime::setTimezone( $timezone ) Parameters: This function accepts two parameters as mentioned above and described below: $object: It is a mandatory parameter which is used to specify the DateTime object which is returned by the date_create() function. $timezone: This parameter is used to set the DateTimeZone object representing the desired time zone. Return Value: This function returns the DateTime object on success or False on failure. Below programs illustrate the date_timezone_set() function in PHP: Program 1: php <?php // Create DateTime object $date = date_create('2018-09-15', timezone_open('Asia/Kolkata')); // Display the date format echo date_format($date, 'd-m-Y H:i:sP') . "\n"; // Set the date time zone date_timezone_set($date, timezone_open('Asia/Singapore')); // Display the date format echo date_format($date, 'd-m-Y H:i:sP'); ?> Output: 15-09-2018 00:00:00+05:30 15-09-2018 02:30:00+08:00 Program 2: php <?php // Create DateTime object $date = new DateTime('2018-09-15', new DateTimeZone('Asia/Kolkata')); // Display the date format echo $date->format('d-m-Y H:i:sP') . "\n"; // Set the date time zone $date->setTimezone(new DateTimeZone('Asia/Singapore')); // Display the date format echo $date->format('d-m-Y H:i:sP'); ?> Output: 15-09-2018 00:00:00+05:30 15-09-2018 02:30:00+08:00 Related Articles: PHP | time_nanosleep( ) Function PHP | timezone_name_from_abbr() Function Reference: http://php.net/manual/en/datetime.settimezone.php Comment More infoAdvertise with us Next Article PHP | date_time_set() Function V vijay_raj Follow Improve Article Tags : Misc Web Technologies PHP PHP-date-time PHP-function +1 More Practice Tags : Misc Similar Reads PHP | date_time_set() Function The date_time_set() function is an inbuilt function in PHP which is used to sets the time. This function resets the current time of the DateTime object to a different time. Syntax: Procedural style: date_time_set( $object, $hour, $minute, $second, $microseconds ) Object oriented style: DateTime::set 2 min read PHP | date_default_timezone_set() Function The date_default_timezone_set() function is an inbuilt function in PHP which is used to set the default timezone used by all date/time functions in a script. This function returns False if the timezone is not valid, or True otherwise. Syntax: bool date_default_timezone_set( $timezone_identifier ) Pa 2 min read PHP | date_timezone_get() Function The date_timezone_get() function is an inbuilt function in PHP which is used to return time zone relative to given DateTime. This function returns a DateTimeZone object on success or False on failure. Syntax: Procedural style: date_timezone_get( $object ) Object oriented style: DateTime::getTimezone 1 min read PHP | date_timestamp_set() Function The date_timestamp_set() function is an inbuilt function in PHP which is used to sets the date and time based on an Unix timestamp. This function returns the DateTime object for method chaining or False on failure. Syntax: Procedural style: date_timestamp_set( $object, $unixtimestamp ) Object orient 2 min read PHP | DateTimeImmutable::setTimezone() Function The DateTimeImmutable::setTimezone() function is an inbuilt function in PHP which is used to set the time zone for the created DateTimeImmutable object. This function returns the DateTimeImmutable object or False on failure. Syntax: DateTimeImmutable::setTimezone ( TimeZone ) Parameters: This functi 1 min read PHP | DateTime setDate() Function The DateTime::setDate() function is an inbuilt function in PHP which is used to reset the current date of DateTime object with the given date-time object. Syntax: Object oriented style: DateTime DateTime::setDate( int $year, int $month, int $day ) Procedural style: DateTime date_date_set( DateTime $ 2 min read Like