Re: RFC for Adding __toString to DateTime
| From: | Derick Rethans | Date: | Sun, 02 Sep 2012 17:20:36 +0000 |
| Subject: | Re: RFC for Adding __toString to DateTime | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-62677@lists.php.net to get a copy of this message | ||
On Sun, 2 Sep 2012, Andrew Faulds wrote:
> On 02/09/12 14:40, Benjamin Eberlei wrote:
> > I think allowing to change teh default format would be horrible. If
> > libraries (such as Doctrine would) use this internally, they are at the will
> > of users not to fiddle with this setting. Not to speak about libraries that
> > contradict each other.
> >
> > If there was a format, it would have to be constant imho.
>
> Then ISO8601, please. It's a single, unambiguous Date and Time format.
No it's not unambigious:
$ php -r 'date_default_timezone_set("Europe/London"); echo
date_create()->format(DateTime::ISO8601), "\n";'
2012-09-02T18:17:36+0100
$ php -r 'date_default_timezone_set("Africa/Niamey"); echo
date_create()->format(DateTime::ISO8601), "\n";'
2012-09-02T18:19:05+0100
vs:
$ php -r 'date_default_timezone_set("Africa/Niamey"); echo
date_create("2012-12-31")->format(DateTime::ISO8601), "\n";'
2012-12-31T00:00:00+0100
^^^^^
$ php -r 'date_default_timezone_set("Europe/London"); echo
date_create("2012-12-31")->format(DateTime::ISO8601), "\n";'
2012-12-31T00:00:00+0000
^^^^^
cheers,
Derick