This article provides several php functions for getting the current time, such as date and time. It also shows me how to solve the time zone problem.
Php tutorial to obtain the current time function
This article provides several php functions for getting the current time, such as date and time. It 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 Functions
$ 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. The default time difference between the php environment and the Beijing time is 8 hours. To get the correct time, you must set it.
Add date_default_timezone_set ('prc') at the beginning of the PHP file ');
Or in php. ini, date. timezone = prc; timeout.
Remember to modify php. ini to restart apache.
This site original tutorials Reprinted with the source of http://www.bkjia.com/phper/php.html