PHP: Problem with strtotime

前端 未结 4 1542
长发绾君心
长发绾君心 2020-12-21 19:02

What\'s going on with strtotime here?

$today = date(\'m.d.y H:i\', time());
echo strtotime($today);

It does not output anything... What\'s

4条回答
  •  再見小時候
    2020-12-21 19:23

    strtotime() is a function for formatting the date, before it is outputted. It seems like the date is already formated in the date() function, and that you make no attempt to format the date in the second line.

    Correct code

    $today = date("Y-m-d-H.i");
    $datenumber = date('Y-m-d',strtotime($today));
    $timenumber = date('H.i',strtotime($today));
    

    You can echo all those variables.

提交回复
热议问题