On Sat, Sep 1, 2012 at 9:54 PM, Stas Malyshev <smalys...@sugarcrm.com>wrote:
> Hi! > > > I would like to officially introduce an RFC with a patch to implement > > __toString to DateTime. This is a commonly requested feature that goes > > unanswered mostly because of the inability to agree on a default pattern. > > This must indicate there's actually no default pattern that is "default" > for everyone. Which suggests maybe we shouldn't have default string > conversion there? > After all, nothing prevents one from having: > > class MyDateTime extends DateTime { > public function __toString() { > return $this->format(/* whatever my favorite format is */); > } > } > > I'm not sure introducing special state to DateTime for it is the best > way to handle it. Also, most applications would have common date format > - which means since the state is per DateTime object, they'd have to > watch that every object produced would have this property set. I think > it'd be easier to just use DateTime->format() - this way you know what > is produced and it is clear for whoever is reading the code too. > Hi, Stas. This has been on my mind as well. I've considered that maybe an INI wide setting would be beneficial here. In fact, there are many places within applications I've worked on where the format for many DateTime objects are the same. What are your thoughts on that? > -- > Stanislav Malyshev, Software Architect > SugarCRM: http://www.sugarcrm.com/ > (408)454-6900 ext. 227 >