NOW() function in PHP

前端 未结 20 1669
遥遥无期
遥遥无期 2020-11-28 17:26

Is there a PHP function that returns the date and time in the same format as the MySQL function NOW()?

I know how to do it using date(), b

20条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-28 17:44

    I was looking for the same answer, and I have come up with this solution for PHP 5.3 or later:

    $dtz = new DateTimeZone("Europe/Madrid"); //Your timezone
    $now = new DateTime(date("Y-m-d"), $dtz);
    echo $now->format("Y-m-d H:i:s");
    

提交回复
热议问题