I'm want to know which date is the greater date
<?php
$date1=16/05/19;
$date2=19/04/19;
if ($date1 > $date2) {
echo 'date1 greater than date2';
else {
echo 'Less than';
}
Why do I get "Less than"?
I'm want to know which date is the greater date
<?php
$date1=16/05/19;
$date2=19/04/19;
if ($date1 > $date2) {
echo 'date1 greater than date2';
else {
echo 'Less than';
}
Why do I get "Less than"?
<?php
$date1=new DateTime("16-05-2019");
$date2=new DateTime("19-04-2019");
if ($date1 > $date2) {
echo 'date1 greater than date2';
} else {
echo 'Less than';
}
?>
Here you compare two date objects (see https://www.php.net/manual/en/function.date.php)
Thanks fo you all guys!
now I have new problem :
$last_update=0;
foreach($datetimetextresult as $value1){
$datetime_text = date("d-m-Y", strtotime($value1->datetime));
$date1=new DateTime ($datetime_text);
$text = $value1->text;
if ($last_update <$date1){
$last_update=$date1;
$last_text = $text ;
}
}
I get this eror: "Object of class DateTime could not be converted to int"