Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62710 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13412 invoked from network); 3 Sep 2012 08:16:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Sep 2012 08:16:23 -0000 Authentication-Results: pb1.pair.com header.from=derick@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=derick@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 82.113.146.227 as permitted sender) X-PHP-List-Original-Sender: derick@php.net X-Host-Fingerprint: 82.113.146.227 xdebug.org Linux 2.6 Received: from [82.113.146.227] ([82.113.146.227:40861] helo=xdebug.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EC/B3-25891-25764405 for ; Mon, 03 Sep 2012 04:16:22 -0400 Received: from localhost (localhost [IPv6:::1]) by xdebug.org (Postfix) with ESMTPS id C657B10D5BE; Mon, 3 Sep 2012 09:16:14 +0100 (BST) Date: Mon, 3 Sep 2012 09:16:14 +0100 (BST) X-X-Sender: derick@whisky.home.derickrethans.nl To: Will Fitch cc: Lester Caine , "internals@lists.php.net" In-Reply-To: Message-ID: References: <5042BC3C.7070208@sugarcrm.com> <50435ABE.4010308@ajf.me> <50436412.7010802@ajf.me> <5043C3E9.2010105@ajf.me> <5043C5AF.3060701@ajf.me> <5043C74C.8020400@ajf.me> <5043D8C0.3020802@lsces.co.uk> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: Re: [PHP-DEV] RFC for Adding __toString to DateTime From: derick@php.net (Derick Rethans) On Sun, 2 Sep 2012, Will Fitch wrote: > On Sep 2, 2012 6:08 PM, "Lester Caine" wrote: > > > > Peter Cowburn wrote: > >> > >> Finally, why should "echo $datetime;" be expected to work at all, > >> since 95% of the time it's only going to be echo'd plain like that for > >> debugging purposes as we'll never pick the "right" format to use in > >> everyone's code. When needing to set the "default" (read: > >> per-instance) string format with something like setToStringFormat() or > >> whatever, that becomes*more* work than just calling format(). > > > > > > Hopefully Will now understands just how problematic his request is, and > why it has not been implemented as yet. I'm with you but for a slightly > different reason. I never run anything but UTC on the server. So I'm only > displaying anything other than UTC when handling a client view of the data. > So I would normally be calling format with the client timezone data. > > It is problematic because that is what we choose to make it. Right now, a > catchable fatal error is produced. That is problematic. ISO8601 is not > lossy nor is UTC. This tells me you haven't researched this subject properly. So let me demonstrate once more: $d = date_create( "2012-09-03 09:13:52" ); var_dump( $d ); $s = $d->format( DateTime::ISO8601 ); $d = date_create( $s ); var_dump( $d ); Outputs: class DateTime#1 (3) { public $date => string(19) "2012-09-03 09:13:52" public $timezone_type => int(3) public $timezone => string(13) "Europe/London" } class DateTime#2 (3) { public $date => string(19) "2012-09-03 09:13:52" public $timezone_type => int(1) public $timezone => string(6) "+01:00" } And voila, you've just lost the timezone that belongs to the DateTime object. > We have standards for a reason. I agree that changing that should not > be allowed. I will remove the set/get pattern functions and only print > a standard format. Printing an ISO standard format, which includes the > TZ based on UTC, or even the UTC format itself is a better solution > than a catchable fatal error. I disagree as it is an Ostrich Method. Instead of fixing your problem you'll just be hiding it. Derick