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. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php