The article "PHP Get Current Time Function" provides several functions of PHP to get the current time, date, time, etc., and also tells me how to solve the time zone problem.
php tutorial to get the current time function
The article provides several PHP functions to obtain the current time, date, time, etc., and also tells me how to solve the time zone problem.
Method 1 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 3 $_server['server_time']
Method 4 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.timezone=prc; in php.ini.
Remember to restart apache after modifying php.ini
Please indicate the source when reprinting original tutorials on this site http://www.bkjia.com/phper/php.html