I use a PHP script for a banlist that fetches the date and time, but I have an error and don\'t know how to convert it to \"normal\" time.
It lists me only the date
Based on this image (that you have given in deleted answer) you have milliseconds. Divide milliseconds with 1000 to get seconds.
Probably something like this:
$datetime = date('d.m.Y \u\m H:i \U\h\r', $row['expires'] / 1000);
But, if you get year 1970, that means that you are on 32bit machine, and your fetched INT is out of range. In this case you could just cut last 3 numbers with string function substr()
:
$datetime = date('d.m.Y \u\m H:i \U\h\r', substr($row['expires'], 0, -3));
Convert the date to UNIX timestamp first. Try with -
$datetime = date("d.m.Y \\u\\m H:i \\U\\h\\r", strtotime($row['expires']));
echo "<td>$datetime</td>";
It lists me only the date : 01.01.1970 um 00:00 Uhr
That simply means you are thinking of $row['expires']
incorrectly. That is not a UNIX Timestamp value and is producing an invalid date. It means the value essentially evaluates to 0, which is Jan 1st 1970 in UNIX time
date()
requires you to send a valid Unix timestamp to it (INT 11), is that what you have in database for that field? or it is a date time field?
Try this
echo date("d.m.Y \\u\\m H:i \\U\\h\\r", "2014-10-12"); //invalid
echo date("d.m.Y \\u\\m H:i \\U\\h\\r", time()); //valid: current unix timestamp