Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Comparing dates via > and < operators

All across my php code i'm storing dates and times in UTC, but i'm also using mysql to store datetimes (also in utc).

is there any way that date comparisons can fail with the greater than and less than operator?

        $curdate=date('Y-m-d H:i:s');
        if($start_datetime>$curdate)
like image 251
siliconpi Avatar asked Jul 29 '26 22:07

siliconpi


1 Answers

Nope.
There is no way for them to fail.
Mysql date format is intentionally made for this purpose.

There is not a single reason to convert it in whatever else format to compare.

like image 115
Your Common Sense Avatar answered Aug 01 '26 11:08

Your Common Sense



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!