Created
March 8, 2013 15:54
-
-
Save stephenmelrose/5117425 to your computer and use it in GitHub Desktop.
Comparing two objects that have internal date properties with DateTime objects assigned to them. Why does this work?!
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 | |
class MyTest { | |
protected $date; | |
public function __construct($time) { | |
$this->date = new DateTime($time); | |
} | |
} | |
$test1 = new MyTest('2013-02-01 00:00:00'); | |
$test2 = new MyTest('2013-03-01 00:00:00'); | |
var_dump($test1 < $test2); // Outputs "true" | |
var_dump($test1 > $test2); // Outputs "false" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment