Php code no more working

This code worked, but now is doesn’t any more:

$now = date('m-d-Y');
$end = date('15-09-2023');  
if ($now <= $end)
{echo "some text"; }

The text appears even after the end date.

date() yields a string.
STRING comparing “02-09-2024” and “15-09-2023” will always yield that now < end because “0” < “1”.
If you want to use string comparisons for dates, put them in Y-m-d format. (incidentally, why are you trying to compare a m-d-Y and something that starts with a 15?)

2 Likes

you are right! (the example 15-09 is crazy :grinning:)
putting Y-m-d, it works!
Thank you very much!

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.