php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20048 mktime() returns -1 for dates < 1970
Submitted: 2002-10-23 14:23 UTC Modified: 2002-10-23 15:18 UTC
Votes:13
Avg. Score:4.7 ± 0.6
Reproduced:10 of 11 (90.9%)
Same Version:5 (50.0%)
Same OS:4 (40.0%)
From: jamie at hometownsports dot ca Assigned:
Status: Wont fix Package: Unknown/Other Function
PHP Version: 4.2.2 OS: RedHat Linux 7.3
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jamie at hometownsports dot ca
New email:
PHP Version: OS:

 

 [2002-10-23 14:23 UTC] jamie at hometownsports dot ca
glibc-2.2.5-34 and greater has been changed to return -1 for dates < 1970.  This used to work.  The problem exists with RedHat 7.3 and 8.0

echo (mktime(0, 0, 0, 1, 1, 1960));  // prints -1

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-10-23 14:26 UTC] jamie at hometownsports dot ca
glibc-2.2.5-34 and greater has been changed to return -1 for dates < 1970.  This used to work.  The problem exists with RedHat 7.3 and 8.0

echo (mktime(0, 0, 0, 1, 1, 1960));  // prints -1
 [2002-10-23 15:18 UTC] hholzgra@php.net
unix timestamp behavior for negative values is undefined

it *may* map to pre-1970 dates but there is no guarantee
whatsoever
 [2003-02-27 00:55 UTC] jlim at natsoft dot com dot my
As a workaround, you can use the adodb_time library, that uses PHP code to calculate negative timestamps.

http://php.weblogs.com/adodb_date_time_library
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Mon Nov 19 18:01:29 2018 UTC