Created
June 20, 2013 20:20
-
-
Save MontealegreLuis/5826243 to your computer and use it in GitHub Desktop.
Difference in hours between two dates.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$now = new DateTime('now', new DateTimeZone('America/Mexico_City')); | |
$twoHoursAgo = clone $now; | |
$twoHoursAgo = $twoHoursAgo->sub(new DateInterval('PT2H')); | |
$diff = $now->diff($twoHoursAgo); | |
echo $diff->format("%H hours\n"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment