Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64049 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 30895 invoked from network); 26 Nov 2012 12:05:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Nov 2012 12:05:39 -0000 Authentication-Results: pb1.pair.com smtp.mail=ivan.enderlin@hoa-project.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=ivan.enderlin@hoa-project.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain hoa-project.net from 95.130.12.24 cause and error) X-PHP-List-Original-Sender: ivan.enderlin@hoa-project.net X-Host-Fingerprint: 95.130.12.24 host1.trois-doubles.net Linux 2.6 Received: from [95.130.12.24] ([95.130.12.24:44930] helo=host1.trois-doubles.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E1/E4-26957-21B53B05 for ; Mon, 26 Nov 2012 07:05:38 -0500 Received: from Hwhost2.local (107-178.203-62.cust.bluewin.ch [62.203.178.107]) by host1.trois-doubles.net (Postfix) with ESMTPSA id 01A8C201095 for ; Mon, 26 Nov 2012 13:05:34 +0100 (CET) Message-ID: <50B35B0E.8070005@hoa-project.net> Date: Mon, 26 Nov 2012 13:05:34 +0100 Reply-To: ivan.enderlin@hoa-project.net User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:19.0) Gecko/19.0 Thunderbird/19.0a2 MIME-Version: 1.0 To: internals@lists.php.net References: <50B34D21.4080109@hoa-project.net> <50B35244.2020706@hoa-project.net> In-Reply-To: Content-Type: multipart/alternative; boundary="------------030303020300060104020202" Subject: Re: [PHP-DEV] DateTime::modify('now') is ignored, why? From: ivan.enderlin@hoa-project.net ("Ivan Enderlin @ Hoa") --------------030303020300060104020202 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 26/11/12 13:02, Derick Rethans wrote: > On Mon, 26 Nov 2012, Ivan Enderlin @ Hoa wrote: > >> On 26/11/12 12:25, Sebastian Krebs wrote: >>> 2012/11/26 Ivan Enderlin @ Hoa >>> >>>> I would to modify a \DateTime object to the current time, thus I wrote >>>> this: >>>> >>>> $d = new \DateTime('+1 hour'); >>>> $d->modify('now'); >>>> >>>> It did not work. Why? Because the documentation (http://php.net/datetime.* >>>> *formats.relative ) says: "Now >>>> - this is simply ignored". Really? But the behavior is pretty >>>> straightforward isn't? "modify to now" means "set to the current date and >>>> time and let the timezone unchanged". >>>> >>> It's not like "modify to something", but "modify _with_ something". With >>> your point of view "modifiy('+7 days')" will _always_ point to next week, >>> but it should (and it's intuitive right), that it will point to 7 days >>> after the previous date. So what should "modify with now" mean? >> I understand the different, but then, why "now" is declared in the >> documentation :-) ? > Because people (like you) have tried it before and found it to not do as > they thought :-) It would have been better never write this keyword ;-). Thanks. Have a good day. PS: In the french version of the documentation, the "it is ignored" was missing. I have submitted a patch. -- Ivan Enderlin Developer of Hoa http://hoa.42/ or http://hoa-project.net/ PhD. student at DISC/Femto-ST (Vesontio) and INRIA (Cassis) http://disc.univ-fcomte.fr/ and http://www.inria.fr/ Member of HTML and WebApps Working Group of W3C http://w3.org/ --------------030303020300060104020202--