downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

DateTimeZone::listAbbreviations> <DateTimeZone::getOffset
[edit] Last updated: Fri, 07 Jun 2013

view this page in

DateTimeZone::getTransitions

timezone_transitions_get

(PHP 5 >= 5.2.0)

DateTimeZone::getTransitions -- timezone_transitions_getDevuelve todas las transiciones para una zona horaria

Descripción

Estilo orientado a objetos

public array DateTimeZone::getTransitions ([ int $timestamp_begin [, int $timestamp_end ]] )

Estilo por procedimientos

array timezone_transitions_get ( DateTimeZone $object [, int $timestamp_begin [, int $timestamp_end ]] )

Parámetros

object

Estilo por procesos solamente: Un objeto DateTimeZone es devuelto por timezone_open()

timestamp_begin

Marca de tiempo de inicio.

timestamp_end

Marca de tiempo final.

Valores devueltos

Deveulve una matriz numérica que contiene una matriz asociativa con todas las transiciones si se tuvo éxito o FALSE en caso de error.

Historial de cambios

Versión Descripción
5.3.0 Se añadireon los parámteros opcionales timestamp_begin y timestamp_end.

Ejemplos

Ejemplo #1 Un ejemplo de timezone_transitions_get()

<?php
$zona_horaria 
= new DateTimeZone("Europe/London");
$transiciones $zona_horaria->getTransitions();
print_r(array_slice($transiciones03));
?>

El resultado del ejemplo sería algo similar a:

Array
(
    [0] => Array
        (
            [ts] => -2147483648
            [time] => 1901-12-13T20:45:52+0000
            [offset] => 3600
            [isdst] => 1
            [abbr] => BST
        )

    [1] => Array
        (
            [ts] => -1691964000
            [time] => 1916-05-21T02:00:00+0000
            [offset] => 3600
            [isdst] => 1
            [abbr] => BST
        )

    [2] => Array
        (
            [ts] => -1680472800
            [time] => 1916-10-01T02:00:00+0000
            [offset] => 0
            [isdst] => 
            [abbr] => GMT
        )

)



add a note add a note User Contributed Notes DateTimeZone::getTransitions - [1 notes]
up
1
scotts
3 years ago
Getting a timezone's offset and other data at a specified point in time (now, for example) using the new PHP5.3 parameters:

<?php
$theTime
= time(); # specific date/time we're checking, in epoch seconds.

$tz = new DateTimeZone('America/Los_Angeles');
$transition = $tz->getTransitions($theTime,$theTime);

# only one array should be returned into $transition. Now get the data:
$offset = $transition[0]['offset'];
$abbr = $transition[0]['abbr'];
?>

Before PHP5.3, you'd have to loop through all of the Transitions up until the current point in time, which would be a very inefficient process.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites