Edit report at https://bugs.php.net/bug.php?id=62353&edit=1

 ID:                 62353
 Comment by:         omg00dness at yahoo dot com
 Reported by:        mike dot mackintosh at angrystatic dot com
 Summary:            strtotime fails to interpret time correctly, uses
                     character after decimal point
 Status:             Open
 Type:               Bug
 Package:            Date/time related
 Operating System:   Ubuntu 12.04 x86_64
 PHP Version:        5.4Git-2012-06-18 (snap)
 Block user comment: N
 Private report:     N

 New Comment:

I don't see this as a bug.  I don't even see how you would want to rely on 
FRACTION units.  You always have leap seconds, leap years, localization, etc.  
How do you measure half a year?  The <# of days> / 2?  6 months?  <# of 
seconds> / 2?  One day does not always equal 86,400 seconds.

Besides, the documentation clearly shows this is not supported.

**Go to: http://us.php.net/manual/en/function.strtotime.php

**Under the <time> parameter, click on Date and Time Formats, or go to: 
http://www.php.net/manual/en/datetime.formats.php

**Click on Relative Formats.

It seems like you are trying to do the row with:

Format: number space? (unit | 'week')
Description: Handles relative time items where the value is a number.
Examples: "+5 weeks", "12 day", "-7 weekdays"

If you look up <number> at the top of that same page, you have the regex: 
[+-]?[0-9]+
which clearly DOES NOT accept a decimal point.  It accepts +, -, or nothing, 
followed by one or more DIGITS.

Sorry if my formatting/caps seem a bit awkward or harsh, but I don't have the 
liberty to add tags here.


Previous Comments:
------------------------------------------------------------------------
[2012-06-18 17:03:39] paj...@php.net

fix cat

------------------------------------------------------------------------
[2012-06-18 16:51:12] mike dot mackintosh at angrystatic dot com

On 6/18/2012 12:50 PM Est, when running:

echo date("m/d/y H:i", strtotime("-1.0 day"));

The following is returned:

06/18/12 09:50

(Minus 3 hours).

------------------------------------------------------------------------
[2012-06-18 16:48:54] mike dot mackintosh at angrystatic dot com

The following behavior is also present:

echo date("m/d/y H:i", strtotime("1.5 days ago"));

Results in -5 days, 5 hours.

It would be expected to return -1 day and 12 hours, being relative.

------------------------------------------------------------------------
[2012-06-18 16:32:25] mike dot mackintosh at angrystatic dot com

Description:
------------
PHP fails to interpret correctly the relative time string when a decimal is 
used. PHP will use the character after the decimal point as the 
multiplier/value in timelib_relative_time. Using an integer of 1.0, results in 
no change.

Test script:
---------------
echo date("m/d/y", strtotime("+1.5 years"));
echo date("m/d/y", strtotime("+1.0 years"));

Expected result:
----------------
12/18/13
06/18/13

Actual result:
--------------
06/18/17
06/18/12


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=62353&edit=1

Reply via email to