Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:86109 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79292 invoked from network); 4 May 2015 17:49:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 May 2015 17:49:07 -0000 Authentication-Results: pb1.pair.com smtp.mail=stelian.mocanita@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=stelian.mocanita@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.48 as permitted sender) X-PHP-List-Original-Sender: stelian.mocanita@gmail.com X-Host-Fingerprint: 209.85.215.48 mail-la0-f48.google.com Received: from [209.85.215.48] ([209.85.215.48:36476] helo=mail-la0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DA/10-10992-F01B7455 for ; Mon, 04 May 2015 13:49:03 -0400 Received: by lagv1 with SMTP id v1so109576611lag.3 for ; Mon, 04 May 2015 10:49:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=oO+0LefWqQU5/fcPVj2EGvKsSsbvvCv2SpDfVslY1gA=; b=iFaXqjA9yCyQA8z/0+OA9+E8LyRufMaT9ak8A/D27qm+KwOF1yOgJmGYbB9ew6XKfP QPMz+LWrePS2HcWEAv5fVOa/MrdoIe/r+blAhrIfXUFNVOC/9cFXxsmHaOF1mGvjrp0K epjVYn60id8UvmM1yBqEmESe9FphqLP7VhwxaMghncLv7ELutNrP9dvSO5v9nP2FzoVD BRa4oeyQLvK2BK3fKIMZ6q7zQ/EO0okibpsy4NhdcMGslxQA3LUovLJ9DaAzZWNgqSzB EJ1U0QXUrhGpvSx5Nyr7tmcN/WAhDBIvmgh/pFC7LUUokwm3XZ82rrJaoEh5vrfD/uAU NfeA== MIME-Version: 1.0 X-Received: by 10.112.139.130 with SMTP id qy2mr20664848lbb.33.1430761740666; Mon, 04 May 2015 10:49:00 -0700 (PDT) Sender: stelian.mocanita@gmail.com Received: by 10.112.171.229 with HTTP; Mon, 4 May 2015 10:49:00 -0700 (PDT) In-Reply-To: <55479144.7060704@gmail.com> References: <55479144.7060704@gmail.com> Date: Mon, 4 May 2015 19:49:00 +0200 X-Google-Sender-Auth: XIicGXgJqTW5BFZuLGncNGDbBBc Message-ID: To: Markus Fasselt Cc: PHP Internals List Content-Type: multipart/alternative; boundary=001a11c34b4e4f8ca30515452d30 Subject: Re: [PHP-DEV] Adding weekdays to DateTime resets the time From: stelianm@php.net (Stelian Mocanita) --001a11c34b4e4f8ca30515452d30 Content-Type: text/plain; charset=UTF-8 I think the best approach would be to open a bug under https://bugs.php.net/ since this does not look like intended behavior. Regards, Stelian On Mon, May 4, 2015 at 5:33 PM, Markus Fasselt wrote: > 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 > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > --001a11c34b4e4f8ca30515452d30--