Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129803 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id A0A2E1A00BC for ; Wed, 21 Jan 2026 14:47:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1769006882; bh=JbmB0YAZxrfBfLeG5y+pwNryfvKUH36bQWCnc1b3fcE=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=nk7gYYhSwYBQ3JY5/tcaET88i8NnTkBVLRDxTqjJCRLgq+pVI+kmzXNJzJm29J/A5 gdWsltL2x44zeOYBb/qwu3GA95JDfDhX7qUo3FwOVMrisiYnSNZhGWg8NAl+2YabPW IhUZha3swj9NHm7GMRXwguuTei0SKIxnY2zUpOVf1C2ly4OiGHUTbLDUMWllqKULd/ wN5XbPWqB0ljv+uUWJ8miiGAw00pcloMID92eQggaMUAswOADUMKkJaCq/ikr6CkYZ aQ7bdW9lD6XYHwrEt6riuOIBBXFJ/8s7rY8+3ZFDLgOUnng3zZ54X9dKPLrAbpH80X MIHqWTd41ntjA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 97BD818002F for ; Wed, 21 Jan 2026 14:48:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: *** X-Spam-Status: No, score=3.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE, SPF_SOFTFAIL autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail.xdebug.org (mail.xdebug.org [176.126.244.128]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 21 Jan 2026 14:48:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1769006875; bh=JbmB0YAZxrfBfLeG5y+pwNryfvKUH36bQWCnc1b3fcE=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=cXoXRk91m8cLTmE3oK+cfvebVJCefBeS22Hzs+xXLYWL4kwyy3e+Fgybe1girO3Jo oLP2j9O4RNxY5UmG6/7fDRg0wQWRodu1grm3KQ5zmAmRnULKuvbt80nznw+lvJKQgr HnDR1wkBE6RIz24g0yC8fOJNofClAwkJANX4iTGu+jlKUhJZpIRSfs9wx28uhYz5i3 x8ZH7WxLhQT0tF2UyZyCkpZ5GlYk/U83lv2Qaisfg8TWTsh+Hq5LLNXo9H8TuT/kFP P0zhSnE9UywK32Fa4hsKpCBFC3FQisysncJGlN4PndG2UnmminKYALUrjUk6ZdX1tj sIxn1/pd5bgeQ== Received: from localhost (localhost [IPv6:::1]) by mail.xdebug.org (Postfix) with ESMTPS id 1AB57200BF; Wed, 21 Jan 2026 14:47:55 +0000 (UTC) Date: Wed, 21 Jan 2026 14:47:54 +0000 (GMT) To: Kamil Tekiela cc: PHP internals Subject: Re: [PHP-DEV] Was deprecation of DATE_RFC7231 and DateTimeInterface::RFC7231 a mistake? In-Reply-To: Message-ID: <4059bd56-127a-2f9b-9fcf-1b875e249c8d@php.net> References: Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII From: derick@php.net (Derick Rethans) Hi, On Wed, 21 Jan 2026, Kamil Tekiela wrote: > I was one of the yes-voters for the > https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_date_rfc7231_and_datetimeinterfacerfc7231 > however, I would like to change my vote to no now. > > The explanation for the deprecation wasn't very clear, and I feel I > was slightly misled by it. It claims that the constant was > implemented by mistake, but I don't think that was the case. > > DATE_RFC7231 follows the timestamp specification from the HTTP format. > It has been repeated by the current RFC 9110 > https://www.rfc-editor.org/rfc/rfc9110#section-5.6.7 The GMT part > isn't a mistake; it's hardcoded as part of the format. Thus, the > constant is implemented correctly in PHP. No, it wasn't. It would format according to local time and just add "GMT" to the end: https://www.php.net/manual/en/class.datetimeimmutable.php (docs haven't been updated for it). > It's true that this could lead to unexpected results when you format a > DateTime that isn't in UTC, but that's a programmer mistake and not > the fault of the constant. The format is timezone agnostic so it's the > responsibility of the programmer to ensure the DateTime object is in > UTC before formatting. Formatters are *only* for local time, and do not currently have the possibility to change the timezone to UTC. So I disagree, as people rightfully should have expected PHP to handle a specific pre-cooked format to behave as the RFC that is named after ought to behave. > Users are now faced with having to replace the constant with its > string value, despite the constant having a well-defined use and > producing correct and "wanted" results. This is more error-prone than > accidentally forgetting to call setTimezone(DateTimeZone::UTC). > Deprecating this constant hasn't improved anything for PHP users and > only made things worse. > > What do you think? Should we undeprecate these constants? No, I don't believe we should put them back as they were. I can think of two possible ways: 1. We could think about adding specific formatting *methods*, such as "asRfc7231String()". This would allow for it to handle the timezone "fix" and also return the right format. Constants aren't the way forwards here. But that also means, that we probably should have methods for other useful formats / specifications too. 2. Create a new formatting specifier which has a specfic meaning to set the timezone to UTC when used at the beginning of the string, say "-". There is some precedent with special formatting letters with DateTimeImmutable::createFromFormat. The constant value then could be "-D, d M Y H:i:s \\G\\M\\T" I don't really like either of these though. cheers, Derick -- https://derickrethans.nl | https://xdebug.org | https://dram.io Author of Xdebug. Like it? Consider supporting me: https://xdebug.org/support mastodon: @derickr@phpc.social @xdebug@phpc.social