Skip to content

Instantly share code, notes, and snippets.

@gustavderdrache
Forked from grahamc/background.md
Created May 18, 2012 19:16
Show Gist options
  • Save gustavderdrache/2727123 to your computer and use it in GitHub Desktop.
Save gustavderdrache/2727123 to your computer and use it in GitHub Desktop.
  • Mac OS X 10.7.4
  • PHP 5.3.8 (system-supplied)
> php
<?php
$startDate = new DateTime('@100');
$endDate = new DateTime('@200');
$oneSecondInterval = new DateInterval('PT1S');
echo "Start date, @100: " . dt_format($startDate) . "\n";
echo "End date, @200: " . dt_format($endDate). "\n";
echo "\n";
$startDate->add($oneSecondInterval);
echo "New Start Date, @100 + PT1S: " . dt_format($startDate) . "\n";
function dt_format(DateTime $dt)
{
return $dt->format('r') . " - " . $dt->getTimestamp();
}
Start date, @100: Thu, 01 Jan 1970 00:01:40 +0000 - 100
End date, @200: Thu, 01 Jan 1970 00:03:20 +0000 - 200
New Start Date, @100 + PT1S: Thu, 01 Jan 1970 01:01:41 +0000 - 3701
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment