Bug #81569 [NEW]: Relative time with decimal value

From: Date: Sat, 30 Oct 2021 10:25:40 +0000
Subject: Bug #81569 [NEW]: Relative time with decimal value
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-237433@lists.php.net to get a copy of this message
From:             tm8544 at hotmail dot com
Operating system: Windows 10 x64
PHP version:      8.1.0RC5
Package:          Date/time related
Bug Type:         Bug
Bug description:Relative time with decimal value

Description:
------------
In PHP Manual
›Supported Date and Time Formats
›Relative Formats

number format is
[+-]?[0-9]+
, 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:
---------------
<?php

// 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:
----------------
30.10.2022
// 1 year ahead

30.10.2020
// 1 year backwards

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

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



-- 
Edit bug report at https://bugs.php.net/bug.php?id=81569&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=81569&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=81569&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=81569&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=81569&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=81569&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=81569&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=81569&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=81569&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=81569&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=81569&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81569&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=81569&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=81569&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=81569&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=81569&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=81569&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=81569&r=mysqlcfg


Thread (2 messages)

« previous php.bugs (#237433) next »