php – – mktime – Problém s rokem 2038

Od posmura

 

Místo mktime() používat DateTime().

$TS = mktime (4, 15, 7, 1, 19, 2038);
echo “<li><font color=’red’>19.1.2038 7:15:04 -> ” . date (“d.m.Y – H:i:s”, $TS) . “</font></li>”;

$TS = new DateTime(‘2042-12-31 22:33:44’);
echo “<li><font color=’green’>31.12.2042 22:33:44 -> ” . $TS->format(‘d.m.Y – H:i:s’) . “</font></li>”;

<li><font color=’red’>19.1.2038 7:15:04 -> 01.01.1970 – 01:00:00</font></li>

<li><font color=’green’>31.12.2042 22:33:44 -> 31.12.2042 – 22:33:44</font></li>