Edit report at https://bugs.php.net/bug.php?id=62911&edit=1

 ID:                 62911
 Updated by:         willfi...@php.net
 Reported by:        bdurand-php at ssji dot net
 Summary:            Add DateTime::__toString()
-Status:             Re-Opened
+Status:             Wont fix
 Type:               Feature/Change Request
 Package:            Date/time related
 PHP Version:        Irrelevant
 Assigned To:        willfitch
 Block user comment: N
 Private report:     N



Previous Comments:
------------------------------------------------------------------------
[2012-09-01 10:18:12] willfi...@php.net

I have reopened this as I've introduced an RFC here: 
https://wiki.php.net/rfc/datetime_tostring.

------------------------------------------------------------------------
[2012-08-27 17:50:28] willfi...@php.net

It's not a matter of whether PHP can or not; it's a matter of gathering a 
consensus among developers on what standard *should* be default.  I personally 
agree with adding __tostring, but this needs to be proposed in an RFC, which I 
will do tonight.

------------------------------------------------------------------------
[2012-08-27 17:27:15] bdurand-php at ssji dot net

The timezone can be defined in the constructor, with the directive tz php.ini, 
or with date_default_timezone_get() function.

A DateTime is a string in fact, so it's logic to have a string cast available. 
Which format is more standard than ISO format? Another common format is the 
timestamp, but it can not represent all dates.
Other languages did this behavior ​​like python. Why PHP can't?

I know that I can subclass any (core) class... it's not the problem here.

------------------------------------------------------------------------
[2012-08-27 15:24:45] willfi...@php.net

Would it be worth investing time in adding a setter/constructor option for a 
default format type? Setting no default could fallback to one of the constants 
(which still doesn't resolve the non-consensus issue).

------------------------------------------------------------------------
[2012-08-27 15:17:38] der...@php.net

We have had this a few times now, and we should not do this. The main reason is 
that we will never be able to come to a consensus on which format to show. It 
certainly shouldn't have anything that destroys the encoded timezone 
identifiers.

It's perfectly possible to subclass DateTime yourself and add a __toString() 
that returns the datetime in your preferred format though.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=62911


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=62911&edit=1

Reply via email to