How do I get the current date and time in PHP?

后端 未结 30 2383
孤城傲影
孤城傲影 2020-11-22 08:19

Which PHP function can return the current date/time?

30条回答
  •  情书的邮戳
    2020-11-22 08:49

    Normally, this function for date is useful for everyone: date("Y/m/d");

    But time is something different, because the time function depends on either the PHP version or system date.

    So probably use it like this to get our own time zone:

    $date = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
    echo $date->format('H:m:s');
    

    This function shows the 24 hours time.

提交回复
热议问题