skip to Main Content

MySQL subtract bigint value as year

I have a MySQL database which holds one column years_valid_for as bigint and another column completion_date as datetime(6). I have to subtract bigint columns number as years. e.g. years_valid_for is 4 and completion_date is 2023-06-07. I have to subtract 4…

VIEW QUESTION

Can someone explain why there's a one-year difference in the results of PHP's date diff function for these two dates with the same timezone?

$a = new DateTime("2023-05-31", new DateTimeZone('Europe/Rome')); $b = new DateTime("1970-05-31", new DateTimeZone('Europe/Rome')); var_dump($a->diff($b)->y); // int(52) $a = new DateTime("2023-05-30", new DateTimeZone('Europe/Rome')); $b = new DateTime("1970-05-30", new DateTimeZone('Europe/Rome')); var_dump($a->diff($b)->y); // int(53) Why in the first case the diff is 52? I…

VIEW QUESTION
Back To Top
Search