php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76397 -n month is not sequential
Submitted: 2018-05-31 15:58 UTC Modified: 2018-05-31 16:03 UTC
From: i at cmsis dot me Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.6.36 OS: linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: i at cmsis dot me
New email:
PHP Version: OS:

 

 [2018-05-31 15:58 UTC] i at cmsis dot me
Description:
------------
on 05-31 run strtotime('-1 month') and strtotime('-2 month') the month is not sequential

Test script:
---------------
echo date('Y-m-d H:i:s', strtotime('-1 month')) . "\n";
echo date('Y-m-d H:i:s', strtotime('-2 month')) . "\n";

Expected result:
----------------
the month should be sequential

Actual result:
--------------
-1 month for 05
and -2 month for 03

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-05-31 16:03 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2018-05-31 16:03 UTC] requinix@php.net
May 31st - 1 month = April 31st which doesn't exist and so overflows to May 1st.
May 31st - 2 months = March 31st which does exist.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri May 09 05:01:27 2025 UTC