Php gets the current time function. 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 get the current time function php to get the current time function article provides several php functions to get the current time, date, time, etc. Oh, also tell me how to solve the time zone problem Oh.
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
Bytes. Php Tutorial to obtain the current time function...