dongmou9260 2018-09-05 14:13
浏览 73

如何在php中从服务器获取日期和时间

my problem is when the time and date stored in database the result in database is 0000-00-00 00:00:00.000000. how do the results match with the current time and date???

for this i used following the code:

$dateandtime = $_SERVER['REQUEST_TIME'];

  • 写回答

3条回答 默认 最新

  • dsi37923 2018-09-05 14:23
    关注

    Use date() as the function formats a local date and time, and returns the formatted date string. Example:-

      $date = date('m/d/Y H:i:s ', time());
    

    This prints date and time in 24 hour format. For 12 hour with am/pm use:-

     $date = date('m/d/Y h:i:s A', time());
    

    I hope it help's you

    评论

报告相同问题?