I have a problem with date comparing logic in MySQL and PHP: date difference functions return different results for the same dates. Example:
SQL
SELECT DATEDIFF('2024-06-02', '2024-05-03 12:57')
30
PHP
$x = date_diff( new DateTime( '2024-06-02' ), new DateTime( '2024-05-03 12:57' ) );
This is causing an assertion error when I pass data selected from the DB with the ‘where DATEDIFF…criteria to PHP that checks the date with the
date_diff()` function.
Is there a strict equivalent for MySQL function in PHP (or vice versa), so that both return 29 (or 30)?