<?php
function tellUnixtime($uts)
{
$s = date('d.m. Y H:i:s', $uts);
if ($s == false){
$s = 'ungültiger Timestamp';
}
return $s;
}
if (isset($_POST['timestamp'])) {
$timestamp = intval($_POST['timestamp']);
print tellUnixtime($_POST['timestamp']);
}else{
$timestamp = '';
}
$current_ts = time();
$current_date = date('d.m.Y H:i:s', $current_ts);
echo <<< EOT
<form action="{$_SERVER['PHP_SELF']}" method="post">
<input type="text" name="timestamp" value="{$timestamp}">
<input type="submit" value="Unix Timestamp als Datum anzeigen">
</form>
Aktueller Unix-Zeitstempel: <strong>$current_ts</strong><br>
Aktuelles Datum, Uhrzeit: <strong>$current_date</strong>
EOT;
?>