I am learning to use PHP DateTime class and I came across the handy 'setDate' method. I tried to do the following to compare 2 dates:
$date = new DateTime();
$newDate = clone $date;
$newDate->setDate(2017, 08, 29);
if($date > $newDate){
echo 'yes';
} else{
echo "no";
}
According to the current date it shall return 'no' but it returned 'yes'. so I did a var_dump($newDate);
and it returned:
object(DateTime)[2]
public 'date' => string '2016-12-29 00:31:02.000000' (length=26)
public 'timezone_type' => int 3
public 'timezone' => string 'Europe/Zurich' (length=13)
It returned 2016-12-29 as the date which is not what I intended to set.
surely there something really wrong with what I am doing. Please help me find my mistake. Thanks