You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just added support for DateTimeImmutable for the next Craft 4 release.
We’re generally no longer maintaining Craft 3, save for security fixes and some other bug fixes when it makes sense, at our discretion. In this case, the fix involves DateTime::createFromImmutable() which was added in PHP 7.3. So until you are ready to update to Craft 4, you will have to ensure you’re passing a DateTime instance into the param.
What happened?
Consider the following:
vs:
This appears to be due to the following checks against
DateTime
specifically:https://github.com/craftcms/cms/blob/3.9.1/src/helpers/Db.php#L1253
https://github.com/craftcms/cms/blob/3.9.1/src/helpers/DateTimeHelper.php#L87
https://github.com/craftcms/cms/blob/4.5.3/src/helpers/Db.php#L1586
https://github.com/craftcms/cms/blob/4.5.3/src/helpers/DateTimeHelper.php#L91
I haven't checked 4.x, but in 3.x changing these to check directly against
DateTimeInterface
gives me the correct result in the first example.Craft CMS version
3.8.9
PHP version
No response
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
The text was updated successfully, but these errors were encountered: