Created
March 8, 2017 22:13
-
-
Save BrunoLagoa/0d0600f5335e0d947f4d1997809890a5 to your computer and use it in GitHub Desktop.
diff.php
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 | |
$datatime1 = new DateTime('2015/04/15 00:00:00'); | |
$datatime2 = new DateTime('2015/05/16 00:00:00'); | |
$data1 = $datatime1->format('Y-m-d H:i:s'); | |
$data2 = $datatime2->format('Y-m-d H:i:s'); | |
$diff = $datatime1->diff($datatime2); | |
$horas = $diff->h + ($diff->days * 24); | |
echo "A diferença de horas entre {$data1} e {$data2} é {$horas} horas"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment