Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:86108 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 72859 invoked from network); 4 May 2015 15:33:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 May 2015 15:33:30 -0000 Authentication-Results: pb1.pair.com smtp.mail=markus.fasselt@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=markus.fasselt@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.177 as permitted sender) X-PHP-List-Original-Sender: markus.fasselt@gmail.com X-Host-Fingerprint: 209.85.212.177 mail-wi0-f177.google.com Received: from [209.85.212.177] ([209.85.212.177:37830] helo=mail-wi0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 11/00-07174-94197455 for ; Mon, 04 May 2015 11:33:29 -0400 Received: by widdi4 with SMTP id di4so114335967wid.0 for ; Mon, 04 May 2015 08:33:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; bh=QkU39lIy8h7M/CPtFJJaYY7sbmDl8YoEw6N64FMhBAg=; b=h9QgPpkH+1IzOq5RuLt+SB8p9vkctQltJRxwkAT02qmAQpMNe0lbHoMOdeJGF3/AnQ nIrk5EiJbGUm2UBIeNwuJg+LPMLXKLtPKudwL+f0PUObLhGBwoSDMzd3nfvm3TbLWUhz M1VJWlNlbF5ziA8gDa6RhacOYcH2RyoNqdlQoM7ttS4QYkjZka0nn2YDwBgHvIHVhyRH WNIv4cEeD2nbKU6dBYad1Rk5dLs1qRoDZg1QqFYvsaG8oj6wewvFklTqUBKbOofOZRVD OnU6LDbPOZU0JGSCF9zZqWP/K0hyeXJ5vBGPD2elBevA0Gf+oTWNmPNM/hPOfzhaVkY2 1M9A== X-Received: by 10.180.99.42 with SMTP id en10mr20712479wib.83.1430753606228; Mon, 04 May 2015 08:33:26 -0700 (PDT) Received: from [192.168.1.137] (f052189094.adsl.alicedsl.de. [78.52.189.94]) by mx.google.com with ESMTPSA id l1sm11695461wiy.20.2015.05.04.08.33.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 May 2015 08:33:25 -0700 (PDT) Message-ID: <55479144.7060704@gmail.com> Date: Mon, 04 May 2015 17:33:24 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: internals@lists.php.net Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Adding weekdays to DateTime resets the time From: markus.fasselt@gmail.com (Markus Fasselt) Hi, when I modify a DateTime object and add or subtract weekdays, it happens that the current time is reset to 00:00:00. This effect does not occur when I add days. I also experienced the same behavior with strototime. > > $a = new DateTime(strtotime('2015-05-04 17:22')); > var_dump((string) $a->format('Y-m-d H:i:s')); // 2015-05-04 17:22:00 > $a->modify('+1 day'); > var_dump((string) $a->format('Y-m-d H:i:s')); // 2015-05-05 17:22:00 > $a->modify('+1 weekday'); > var_dump((string) $a->format('Y-m-d H:i:s')); 2015-05-06 00:00:00 > > var_dump(date('Y-m-d H:i:s', strtotime('+1 weekday'))); // 2015-05-05 00:00:00 http://3v4l.org/554H4 There seems to be slighly different behavior between the different PHP versions. strotime always had this behavior. DateTime::modify() worked correct until PHP 5.3.5. I don't know if this behavior was changed on purpose (I didn't find something on it). If so, why? Otherwise I would suggest to fix this, as it is really confusing. Regards, Markus