mktime pre 1970 confusion (linux)
Posted: Tue Aug 31, 2004 10:20 am
Hi,
I have read a few post on this, but they all seem to be windows, so appologies for repeat post, but not answers as far as I can see.
Now, I'm sure that this never used to do this, as I have had scripts running for a couple of years now that display date of birth infomation, without any complaints (but maybe it's just never been spotted)
But it would appear that I have discovered the pre 1970 bug... Now the PHP manual states that time_t must be 32bit, but I'm using Mandrake 9.2 and Redhat 8, both 32bit platforms as far as I am aware(?) , so surely they shouldn't have this problem.
My advantage is that I have 100's of scripts that reference the following funtion (which is now the one failing) so I only have to replace this code:
It work appear that I can infact pass the date function a valid timestamp that pre date 1970, it is just mktime that is failling.
Is there any solution?
I have read a few post on this, but they all seem to be windows, so appologies for repeat post, but not answers as far as I can see.
Now, I'm sure that this never used to do this, as I have had scripts running for a couple of years now that display date of birth infomation, without any complaints (but maybe it's just never been spotted)
But it would appear that I have discovered the pre 1970 bug... Now the PHP manual states that time_t must be 32bit, but I'm using Mandrake 9.2 and Redhat 8, both 32bit platforms as far as I am aware(?) , so surely they shouldn't have this problem.
My advantage is that I have 100's of scripts that reference the following funtion (which is now the one failing) so I only have to replace this code:
Code: Select all
function formatdate ($format, $dt)
{
/*
* Formats MySQL datetime format to normal format
*/
list($mydate, $mytime) = split(" ", $dt);
if ($mydate == "0000-00-00" || $mydate == "") return "";
list($y, $m, $d) = split("-",$mydate);
list($h, $i, $s) = split(":",$mytime);
return date($format,
mktime(intval($h),
intval($i),
intval($s),
intval($m),
intval($d),
intval($y)
)
);
}Is there any solution?