Link to home
Start Free TrialLog in
Avatar of rafaelri
rafaelri

asked on

timestamp pre 1970 date problem

I've came across a problem, I don't know how to display php timestamps before 1970. There's no problem with the timestamp at all since I'm running a Linux box, but when date function tries to convert it really screws up everything.
Is there any simple way to display pre 70 timestamp dates in php?

Sample:
<?
$timestamp = mktime(0, 0, 0, 3, 28, 1950, 0);
var_dump(date('d-m-y', $timestamp));
?>
Avatar of merwetta1
merwetta1

when I run your sample code, I get:
string(8) "28-03-50"

That looks OK to me. What are you getting? Perhaps it is a PHP or server configuration issue. What is your PHP version and webserver OS?

according to http://php.net/date :
The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT

So you should be OK all the way back to 1901. The issue doesn't seem to be the date() function.
Avatar of Zyloch
Yeah, the timestamp will be negative but the date() shouldn't have a problem.
Avatar of rafaelri

ASKER

The box is a Debian Linux Unstable Running Kernel 2.6.10, PHP 4 and Apache2.
If I var_dump the timestamp, it is fine (has a negative value), the problem seems to occur when I try to convert it to a date, it just displays 31-12-69 when it should be 28-03-50.
Do you know if there's some configuration that could change that behaviour?
ASKER CERTIFIED SOLUTION
Avatar of merwetta1
merwetta1

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.
I will leave the following recommendation for this question in the Cleanup topic area:
Accept: merwetta1

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

Huji
EE Cleanup Volunteer