php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76686 Datetime->sub calculates incorrectly on dates late in a month
Submitted: 2018-07-31 08:01 UTC Modified: 2018-07-31 08:25 UTC
From: janne at consilia dot fi Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 7.0.31 OS:
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: janne at consilia dot fi
New email:
PHP Version: OS:

 

 [2018-07-31 08:01 UTC] janne at consilia dot fi
Description:
------------
The PHP version is actually 7.0.30 (not in the list)

The test script produces the following result:
2018-07-31 
2018-07-01 
2018-06-01


Test script:
---------------
<?php
$now = new DateTime('2018-07-31');
echo $now->format('Y-m-d') . "\n";
echo $now->sub(new DateInterval('P1M'))->format('Y-m-d') . "\n";
echo $now->sub(new DateInterval('P1M'))->format('Y-m-d') . "\n";



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-07-31 08:25 UTC] peehaa@php.net
-Status: Open +Status: Not a bug
 [2018-07-31 08:25 UTC] peehaa@php.net
June has only 30 days so it overflows into July.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 01:01:30 2024 UTC