Original address: http://zhidao.baidu.com/link?url=j325JdrGdItr_4uQgJkdqn4bKRubcrZ1nsh4Hm9mIQa4BSLqWwhOwHtQLOtIiOKa4GzqvhsTXs6ovoVU6wQGVa
Method one date function
echo date('y-m-d h:i:s',time());
/ /2010-08-29 11:25:26
Method 2 time function
$time = time();
echo date("y-m-d",$time) //2010-08-29
Method three $_server['server_time']
Method four strftime
echo strftime ("%hh%m %a %d %b" ,time());
18h24 sunday 21 may
Another problem is the time zone issue. The default time difference of the PHP environment is 8 hours different from Beijing time. If we want to get the correct time, we must set it
Add date_default_timezone_set('prc');
at the beginning of the PHP file Or date.timez/span>
in php.ini. Remember to restart apache after modifying php.ini
The above introduces the method of obtaining the current time in PHP, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.