How to get local time in php?

前端 未结 7 1411
野性不改
野性不改 2021-02-02 03:12

I am trying to get the local time using php. I wrote two different versions, but they both give the wrong time

date_default_timezone_set(\'UTC\');
$now = new Dat         


        
7条回答
  •  终归单人心
    2021-02-02 03:47

    You can solve this problem by using localtime() function or through date_default_timezone_set() function.

    Learn more about the localtime() function reffer:
    http://php.net/manual/en/function.localtime.php

    or

    Learn more about the date_default_timezone_set() function reffer http://www.php.net/manual/en/function.date-default-timezone-set.php

    i think this must help you..

提交回复
热议问题