Datetime Object, And Years

no-email (Frederic Bouchery), Frederic Bouchery
Wed, 27 Nov 2024 00:00:00 +0000

In this code, 2 years are given to datetime, and handed back. Yet, they return the same value: 2024.
Under the hood, PHP attempts to decode the number. Instead of recognizing a year, it recongnizes an hour. And, by default, it set the rest of the date to today. Later, when the date is formatted, the year becomes 2024.
One piece of advice is to format the date to PHP's liking, or use the ``createFromFormat()`` method, which uses a provided format to decode the string.