• PHP Video Tutorials

PHP timezone_transitions_get() Function


Advertisements

Definition and Usage

The timezone_transitions_get() function is an alias of DateTimeZone::getTransitions(). It accepts a DateTimeZone object as a parameter and returns transitions for the given timezone.

Syntax

timezone_transitions_get($object, $timestamp_start, $timestamp_end)

Parameters

Sr.No Parameter & Description
1

object (Mandatory)

This is a DateTimeZone object.

2

timestamp_start (Optional)

An integer value representing the begin timestamp.

3

timestamp_end (Optional)

An integer value representing the end timestamp.

Return Values

PHP timezone_transitions_get() function returns all the transition in the form of an array. Incase of a failure this function returns the boolean value false.

PHP Version

This function was first introduced in PHP Version 5.2.0 and, works with all the later versions.

Example

Following example demonstrates the usage of the date_default_timezone_get function −

Live Demo
<?php
   $tz = new DateTimeZone("Indian/Mahe");
   $list = timezone_transitions_get($tz);
   print_r($list);
?>

This will produce following result −

Array
(
    [0] => Array
        (
            [ts] => -9223372036854775808
            [time] => -292277022657-01-27T08:29:52+0000
            [offset] => 13308
            [isdst] =>
            [abbr] => LMT
        )

    [1] => Array
        (
            [ts] => -2006653308
            [time] => 1906-05-31T20:18:12+0000
            [offset] => 14400
            [isdst] =>
            [abbr] => +04
        )

    [2] => Array
        (
            [ts] => 2147483647
            [time] => 2038-01-19T03:14:07+0000
            [offset] => 14400
            [isdst] =>
            [abbr] => +04
        )

)

Example

$timezone = new DateTimeZone("CET");
print_r(reset($timezone->getTransitions()));
   
echo"------------------------------------------------\n";
   
print_r( reset( timezone_transitions_get ($timezone) ) );

This will produce the following result −

Array (
   [ts] => -1693706400
   [time] => 1916-04-30T22:00:00+0000
   [offset] => 7200
   [isdst] => 1
   [abbr] => CEST
)
------------------------------------------------
Array (
   [ts] => -1693706400
   [time] => 1916-04-30T22:00:00+0000
   [offset] => 7200
   [isdst] => 1
   [abbr] => CEST
)
php_function_reference.htm
Advertisements