|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2015-02-03 19:04 UTC] requinix@php.net
-Status: Open
+Status: Not a bug
[2015-02-03 19:04 UTC] requinix@php.net
[2015-02-03 20:18 UTC] teo8976 at gmail dot com
[2015-02-03 20:27 UTC] requinix@php.net
-Status: Not a bug
+Status: Open
[2015-02-03 20:37 UTC] teo8976 at gmail dot com
[2018-02-27 01:20 UTC] calebpitman at gmail dot com
[2021-04-05 16:01 UTC] derick@php.net
-Status: Open
+Status: Not a bug
[2021-04-05 16:01 UTC] derick@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 20:00:01 2025 UTC |
Description: ------------ The way negative relative month values are handled by strtotime() is 1) undocumented 2) complete nonsense example: strtotime("-3 months", $date) Test script: --------------- $end_date=mktime(23,59,59,12,31,2014); echo date("r", $end_date)."\n"; $date=strtotime("-1 months", $end_date); echo date("r", $date)."\n"; $date=strtotime("-2 months", $end_date); echo date("r", $date)."\n"; $date=strtotime("-3 months", $end_date); echo date("r", $date)."\n"; $date=strtotime("-4 months", $end_date); echo date("r", $date)."\n"; $date=strtotime("-5 months", $end_date); echo date("r", $date)."\n"; $date=strtotime("-6 months", $end_date); echo date("r", $date)."\n"; $date=strtotime("-7 months", $end_date); echo date("r", $date)."\n"; $date=strtotime("-8 months", $end_date); echo date("r", $date)."\n"; $date=strtotime("-9 months", $end_date); echo date("r", $date)."\n"; $date=strtotime("-10 months", $end_date); echo date("r", $date)."\n"; $date=strtotime("-11 months", $end_date); echo date("r", $date)."\n"; $date=strtotime("-12 months", $end_date); echo date("r", $date)."\n"; Expected result: ---------------- Wed, 31 Dec 2014 23:59:59 +0100 Mon, 30 Nov 2014 23:59:59 +0100 Fri, 31 Oct 2014 23:59:59 +0100 Wed, 30 Sep 2014 23:59:59 +0200 Sun, 31 Aug 2014 23:59:59 +0200 Thu, 31 Jul 2014 23:59:59 +0200 Tue, 30 Jun 2014 23:59:59 +0200 Sat, 31 May 2014 23:59:59 +0200 Thu, 30 Apr 2014 23:59:59 +0200 Mon, 31 Mar 2014 23:59:59 +0200 Mon, 28 Feb 2014 23:59:59 +0100 Fri, 31 Jan 2014 23:59:59 +0100 Tue, 31 Dec 2013 23:59:59 +0100 Actual result: -------------- Wed, 31 Dec 2014 23:59:59 +0100 Mon, 01 Dec 2014 23:59:59 +0100 Fri, 31 Oct 2014 23:59:59 +0100 Wed, 01 Oct 2014 23:59:59 +0200 Sun, 31 Aug 2014 23:59:59 +0200 Thu, 31 Jul 2014 23:59:59 +0200 Tue, 01 Jul 2014 23:59:59 +0200 Sat, 31 May 2014 23:59:59 +0200 Thu, 01 May 2014 23:59:59 +0200 Mon, 31 Mar 2014 23:59:59 +0200 Mon, 03 Mar 2014 23:59:59 +0100 << THIS IS PARTICULARLY HILARIOUS Fri, 31 Jan 2014 23:59:59 +0100 Tue, 31 Dec 2013 23:59:59 +0100