Skip to content

Instantly share code, notes, and snippets.

/timezone_bs.php Secret

Created November 2, 2015 18:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/1fd0bc43172ff24cd4b5 to your computer and use it in GitHub Desktop.
Save anonymous/1fd0bc43172ff24cd4b5 to your computer and use it in GitHub Desktop.
<?php
$tz = array(
'Europe/Paris'
,'America/New_York'
);
$dates = array(
array('2014-02-01', '2014-03-01'),
array('2014-06-01', '2014-07-01'),
);
foreach($tz as $zone) {
foreach($dates as $dateTuple) {
$date1 = new DateTime($dateTuple[0], new DateTimeZone($zone));
$date2 = new DateTime($dateTuple[1], new DateTimeZone($zone));
echo $date1->diff($date2)->format('P%yY%mM%dDT%hH%iM%sS') . "\t{$zone}" . PHP_EOL;
echo $date1->format(DateTime::ISO8601) . PHP_EOL;
echo $date2->format(DateTime::ISO8601) . PHP_EOL . PHP_EOL;
}
}
exit(0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment