php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52154 mktime(0,0,0,0,0,0) returns a timestamp instead of false
Submitted: 2010-06-23 10:27 UTC Modified: 2010-06-23 11:48 UTC
From: j dot logemann at qmulus dot nl Assigned:
Status: Duplicate Package: Date/time related
PHP Version: 5.3.2 OS: Windows 7 enterprise
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: j dot logemann at qmulus dot nl
New email:
PHP Version: OS:

 

 [2010-06-23 10:27 UTC] j dot logemann at qmulus dot nl
Description:
------------
When you try to get the timestamp for day 0 of month 0 of the year 0, php returns 943916400 instead of false. It should return false because the input is clearly an invalid date and "0000-00-00" is not equal to "1999-11-30"

Test script:
---------------
<?php
echo mktime(0,0,0,0,0,0);

Expected result:
----------------
According to the documentation:
"mktime() returns the Unix timestamp of the arguments given. If the arguments are invalid, the function returns FALSE (before PHP 5.1 it returned -1)."

Therefore the output should be FALSE and not 943916400





Actual result:
--------------
The actual result = 943916400

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-06-23 11:48 UTC] salathe@php.net
-Status: Open +Status: Duplicate
 [2010-06-23 11:48 UTC] salathe@php.net
This is expected behaviour. Using 0 for the year maps, as documented, to the year 
2000; 0 for the month means December of the previous year (December 1999), 0 for 
the day-of-month means the last day of the previous month (30th November 1999). 
Therefore your date values do not map to "0000-00-00" as you expected, but 
correctly as you found to "1999-11-30 00:00:00" -- the arguments are not invalid, 
so FALSE is not returned.

Duplicate of bug #36027
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC