PHP date () error for high timestamps on 32bit
I came across this problem:
<?php
echo date('r', 4567743118);
Desired and correct result (on localhost):
Sun, 30 Sep 2114 10:31:58 +0100
Invalid result (on the remote):
Thu, 24 Aug 1978 04:03:42 +0100
A bad result is obtained when running the script on a 32 bit platform. I think this is the famous Y2038 problem, but how to fix it?
If I iterate over the timestamp (when stored in a variable) it displays fine but date()
destroys it (assuming I am using int32).
<?php
$a = 4567743118;
echo $a;
4567743118
[this is PHP 5.4.4 from debian repos if applicable]
+3
source to share