PHP 8.2: DateTime::COOKIE constant value changed from l, d-M-Y H:i:s T to D, d-M-Y H:i:s T

Version8.2
TypeChange

The DateTime::COOKIE class constant is supposed to hold the date/time format that is used in cookie expiration time, Expires header value, etc.

Prior to PHP 8.2, this constant was erroneously assigned the date-time format l, d-M-Y H:i:s T. The correct time format should be D, d-M-Y H:i:s T, which is corrected in PHP 8.2.

From PHP 8.2, and later, date/time values formatted using the DateTime::COOKIE constant will be changed to use the abbreviated day, instead of the full day:

- l, d-M-Y H:i:s T → Sunday, 26-Sep-2021 16:58:51 UTC
+ D, d-M-Y H:i:s T → Sun, 26-Sep-2021 16:58:51 UTC

IETF RFC 7234 - 5.3 and RFC 7231 - 7.1.1.1 define the correct date format (now used in PHP 8.2 and later).

Backwards Compatibility Impact

Applications that relied on the DateTime::COOKIE date format constant might need to be update to make sure it can handle the new date format.

To make sure the date formats are consistent across all PHP versions, it is possible to use either of the date formats directly (although the practice of using magic strings is frowned upon):

- date(DateTime::COOKIE, $timestamp);
+ date('D, d-M-Y H:i:s T', $timestamp);

Implementation