# [PR] DateTime RFC7231 constant

- Thread: https://externals.io/message/78451
- Original archive: https://news-web.php.net/php.internals/78451
- Started by Trevor Suarez on 2014-10-30T07:03:45+00:00
- Messages: 5
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #78451 — Trevor Suarez — 2014-10-30T07:03:45+00:00

URL: https://externals.io/message/78451#78451

Good early morning (late night for me) internals!

I would like to propose a small addition be made to the DateTime date
format constant definitions.

https://github.com/php/php-src/pull/882

This is my first contribution to PHP's core. I wasn't sure if something of
this nature would require an RFC, but I tried to register for a Wiki
account and was met with page errors anyway (if anyone could point me in
the right direction to notify someone of the wiki registration page failing
<https://wiki.php.net/rfc?do=register>, that'd be awesome).

Since I was unable to create an RFC anyway, I attempted to make the pull
request description as close to the RFC template/format as I could. I'm
sorry if I'm missing anything there. Please let me know if I am.

My C skills are near non-existent, but luckily this PR requires very little
C code. :P

Thank you all for your time!

- Trevor

---

## #78461 — Andrea Faulds — 2014-10-30T11:26:58+00:00

URL: https://externals.io/message/78451#78461 · In reply to: #78451

> 
> 
> Good early morning (late night for me) internals!
> 
> I would like to propose a small addition be made to the DateTime date
> format constant definitions.
> 
> https://github.com/php/php-src/pull/882

Looks simple and unobjectionable. :)

> This is my first contribution to PHP's core. I wasn't sure if something of
> this nature would require an RFC, but I tried to register for a Wiki
> account and was met with page errors anyway (if anyone could point me in
> the right direction to notify someone of the wiki registration page failing
> <https://wiki.php.net/rfc?do=register>, that'd be awesome).

Ah, well, for small additions like constants, an RFC is rarely necessary unless it’s controversial. Though there’s no harm in making one. Usually, if you just make a pull request for it and badger enough people, it’ll be merged eventually.

The reason registration on the wiki no longer works is probably to stop the situation we had before, where there were git (php.net) accounts and wiki accounts, and the former took precedence over the latter. If you want to edit the wiki now, you’ll probably need a php.net account. Then just ask someone for karma in the /rfc/ namespace on the wiki so you can create and edit RFCs. I might be wrong about it being disabled intentionally, though.

--
Andrea Faulds
http://ajf.me/

---

## #78462 — Matteo Beccati — 2014-10-30T11:31:24+00:00

URL: https://externals.io/message/78451#78462 · In reply to: #78451

Hi,


> Good early morning (late night for me) internals!
> 
> I would like to propose a small addition be made to the DateTime date
> format constant definitions.
> 
> https://github.com/php/php-src/pull/882

Thanks for the PR.

However, I'm afraid the comments on the PR code are correct. The output
is supposed to be UTC time, not just local time with "GMT" appended.


Cheers
-- 
Matteo Beccati

Development & Consulting - http://www.beccati.com/

---

## #78463 — Peter Cowburn — 2014-10-30T11:50:54+00:00

URL: https://externals.io/message/78451#78463 · In reply to: #78461

>
> > […]
>
> Looks simple and unobjectionable. :)
>
> > […]
> of
> > […]
> failing
> > […]
>
> Ah, well, for small additions like constants, an RFC is rarely necessary
> unless it’s controversial. Though there’s no harm in making one. Usually,
> if you just make a pull request for it and badger enough people, it’ll be
> merged eventually.
>
> The reason registration on the wiki no longer works is probably to stop
> the situation we had before, where there were git (php.net) accounts and
> wiki accounts, and the former took precedence over the latter. If you want
> to edit the wiki now, you’ll probably need a php.net account. Then just
> ask someone for karma in the /rfc/ namespace on the wiki so you can create
> and edit RFCs. I might be wrong about it being disabled intentionally,
> though.
>

The most common cause of errors is providing an incorrect answer to the
"Which email address do you have to mail now?" question  (the answer is
php-webmaster@lists.php.net).

Registration still works, at the time of writing this. After registering,
and following instructions to mail the webmaster list for rfc karma, you'll
be able to add/edit RFC pages.

Having a php.net VCS account is *not* a requirement at all. Those lucky
enough to have a php.net account do not need to ask for wiki editing karma,
everyone is able to write to all pages.


>
> --
> Andrea Faulds
> http://ajf.me/

---

## #78578 — Chris Wright — 2014-11-03T15:11:52+00:00

URL: https://externals.io/message/78451#78578 · In reply to: #78462

> Hi,
>
> 
> > […]
>
> Thanks for the PR.
>
> However, I'm afraid the comments on the PR code are correct. The output
> is supposed to be UTC time, not just local time with "GMT" appended.
>
>
This is true, and there isn't really a particularly good solution to this
if implementing this as a constant. However, it should be possible to add a
new format character for this (e.g. R) - the constant could be added as
well in this scenario, with value of the new character. This would be a
minor BC break. It's probably still worth considering for (5.)?7, since at
the moment the only way to definitely (and sanely) get this right every
time is via `gmdate()`, which may result in messy code when working with
DateTime etc objects.

Trevor, if you do want to look at implementing this for practice/improving
your C skills etc, it's not a particularly difficult task, it's largely
just a simpler version of the handling of "r", that does not consider the
localtime flag or generate the offset digits. The relevant part of the
source code is here:
http://lxr.php.net/xref/PHP_5_6/ext/date/php_date.c#1189

The "R" format character is available and probably makes the most sense of
the available possibilities, as the format approximately complements "r".

Thanks, Chris
