I have two datetime objects stored in my datebase through a contructor method: App\Entity\Token
public function __construct()
{
$this->creation = new \DateTime("now");
$this->valid = (new \DateTime("now"))->modify('+1 day');
}
When i try to compare those objects with my datetimenow the result isn't as expected, tried many diferents situations, camparing < > or using diff between two dates. Shall i use something special?: Example:
$datenow = new \DateTime("now");
if ( $datenow < $creation && $datenow > $valid ) {
} else{result_always_here}
Could be something related with the format or i must use doctrine in order to compare it?
Thanks.
Kind regards.