Datetime in PHP Script

后端 未结 3 867
走了就别回头了
走了就别回头了 2020-12-22 02:10

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

3条回答
  •  情深已故
    2020-12-22 02:50

    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
    

提交回复
热议问题