php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60563 strtotime(<float var>) returns TRUE
Submitted: 2011-12-19 11:32 UTC Modified: 2011-12-19 12:12 UTC
From: edu2004eu at yahoo dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: Irrelevant OS: Windows (at least)
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: edu2004eu at yahoo dot com
New email:
PHP Version: OS:

 

 [2011-12-19 11:32 UTC] edu2004eu at yahoo dot com
Description:
------------
I have a variable saved as float (checked with var_dump) and if I pass that 
variable to "strtotime()", I get a valid timestamp. For example if my float 
variable is "0.8", I would get "1324249680" as result from strtotime.

Not sure if this is normal, but I would say NO.

Test script:
---------------
echo strtotime(0.8);

$var = 0.8;
echo strtotime($var);

Expected result:
----------------
FALSE

Actual result:
--------------
1324249680

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-12-19 12:12 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

This is correct. The float gets converted to a string ("0.8") and that is interpreted as hour 0 and minute 8. Not every locale uses a : to separate, but some use the ".".
 [2011-12-19 12:12 UTC] derick@php.net
-Status: Open +Status: Bogus
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 21:01:31 2024 UTC