php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #21646 Strftime: negative timestamps
Submitted: 2003-01-14 23:13 UTC Modified: 2003-06-09 13:48 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: wolfandreas at yahoo dot de Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.3.0 OS: all
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: wolfandreas at yahoo dot de
New email:
PHP Version: OS:

 

 [2003-01-14 23:13 UTC] wolfandreas at yahoo dot de
Situation:
The function strftime does return false for negative unix-timestamps.

Problem:
The functions mktime and strtotime return negative values for dates before 1970-01-01 00:00 UT.
Many users try something like:

strftime($format,strtotime($date_before_1970))

and wonder why this does not work.

If the behavior for timestamps before second 0 
(start of Jan 1., 1970 UT) is undefined why do all other time functions return negative values ?
The documentation for strftime does not say anything about negative values for timestamps, too.

Solution:
Let strftime return values (Gregorian calendar) for negative timestamps.
(Perhaps there should be a warning ?)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-14 23:16 UTC] wolfandreas at yahoo dot de
Situation:
The function strftime does return false for negative unix-timestamps.

Problem:
The functions mktime and strtotime return negative values for dates
before 1970-01-01 00:00 UT.
Many users try something like:

strftime($format,strtotime($date_before_1970))

and wonder why this does not work.

If the behavior for timestamps before second 0 
(start of Jan 1., 1970 UT) is undefined why do all other time functions
return negative values ?
The documentation for strftime does not say anything about negative
values for timestamps, too.

Solution:
Let strftime return values (Gregorian calendar) for negative
timestamps.
(Perhaps there should be a warning ?)
 [2003-02-25 23:54 UTC] pollita@php.net
Please do not use "all" for the OS field unless you know for certain that it affects all platforms equally.

Most of the datetime related functions (strftime included) are dependent on what support exists in the libraries on the running system.  An example of this variable behavior is the time() function which returns values from -2147483648 to 2147483647 on most unix platforms, but only returns positive values under windows.

On your platform, strftime() only accepts positive values.  That is not to say that strftime only accepts positive values on all platforms.  Have you tried date()?

The strftime manual page already has a warning stating that not all format specifiers are supported on all platforms, perhaps that should be extended to warn of inconsistent support for timestamp values.
 [2003-06-08 17:37 UTC] mog at nospam dot please
I'm having this problem on Redhat 7.3/PHP4.3.2

On our forum software (vBulletin) members profiles are showing "Dec-31-1969" for people born before 1970.
 [2003-06-09 13:48 UTC] pollita@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 17 17:01:27 2024 UTC