On 30 October 2014 11:31, Matteo Beccati <p...@beccati.com> wrote:

> Hi,
>
> On 30/10/2014 08:03, Trevor Suarez wrote:
> > 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.
>
>
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

Reply via email to