|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81569 Relative time with decimal value
Submitted: 2021-10-30 10:25 UTC Modified: 2021-10-30 19:31 UTC
From: tm8544 at hotmail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 8.1.0RC5 OS: Windows 10 x64
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: tm8544 at hotmail dot com
New email:
PHP Version: OS:


 [2021-10-30 10:25 UTC] tm8544 at hotmail dot com
In PHP Manual
›Supported Date and Time Formats
›Relative Formats

number format is
, no decimal point included.

If number is given with decimal value, number should be cut before decimal point, eg "+1.5" should be read as "+1"
Now, it is read as "5"

Test script:

// in examples below, this script was run at 30.10.2021

echo date("j.n.Y", strtotime("+1.5 year", time()));
echo date("j.n.Y", strtotime("-1.5 year", time()));


Expected result:
// 1 year ahead

// 1 year backwards

Actual result:
// This is 5 years ahead, not 1.5 years ahead

// This is 5 years ahead, not 1.5 years backwards


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-10-30 19:31 UTC]
-Status: Open +Status: Not a bug
 [2021-10-30 19:31 UTC]
You aren't seeing the full picture with just the date portion.

As with other miscellaneous inputs that don't have meaning to the parser, the decimal point acts as a separator, so "+1.5 year" means "+1" and then "5 year".

"+1" is a tzcorrection.
"5 year" is a relative amount.

The result is +1 or -1 hour for the timezone correction and 5 years added to the date.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 20 19:01:33 2024 UTC