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
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: 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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Fri May 09 23:01:31 2025 UTC