Time Zone Calculations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Everyone

The result of the code below (Converting the time from GMT to Eastern , Then adding 561 Days and converting back to GMT) is giving me the result: 2013-11-18 14:32:00    I was expecting an hour earlier (2013-11-18 13:32:00)   Is there something I am doing wrong?  

- I am trying to calculate 561 days in the future, but keeping the same time.

- The reason I thought about converting from GMT to Eastern and back to GMT was because I wondered if Daylight Savings Time was the issue.  

Ron

<?php
$occurance_date = '2012-05-06 13:32:00';

$dt = new \DateTime( date('Y-m-d H:i:s' , strtotime( $occurance_date ) ) , new \DateTimeZone( 'GMT' ) );
$dt->setTimezone(new \DateTimeZone( "Canada/Eastern"  ));
$dt->modify('+561 days');
$dt->setTimezone(new \DateTimeZone( 'GMT'  ));
$revised_occurance_date = $dt->format('Y-m-d H:i:s'); 
?>

Ron Piggott



www.TheVerseOfTheDay.info 

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux