Last active
December 12, 2015 03:38
-
-
Save Taluu/4708093 to your computer and use it in GitHub Desktop.
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 | |
// php wtf of the day | |
use \DateTime, | |
\DateInterval; | |
$now = ['ref'=> new DateTime(), 0 => new DateTime(), 1 => new DateTime]; | |
$interval = new DateInterval('PT10S'); | |
// Have to do this to make it work. Just putting it here, so we can analyse the difference | |
$now[1]->sub($interval)->sub($interval); | |
$tries = [$now[0]->diff($now[0]->sub($interval)->sub($interval), true), //not working... | |
$now['ref']->diff($now[1], true)]; // working | |
var_export($tries); |
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 | |
array ( | |
0 => | |
DateInterval::__set_state(array( | |
'y' => 0, | |
'm' => 0, | |
'd' => 0, | |
'h' => 0, | |
'i' => 0, | |
's' => 0, | |
'invert' => 0, | |
'days' => 0, | |
)), | |
1 => | |
DateInterval::__set_state(array( | |
'y' => 0, | |
'm' => 0, | |
'd' => 0, | |
'h' => 0, | |
'i' => 0, | |
's' => 20, | |
'invert' => 0, | |
'days' => 0, | |
)), | |
)% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment