Brief introduction
PHP to get time is a very easy thing, the following small part on the simple to share some of the experience of the individual learning PHP it;
Operation method
1. Get the current Time method date ()
Quite simply, this is the way to get the time, in the format: Date ($format, $timestamp), format, timestamp timestamp--can be filled in parameters.
2. Get timestamp method Time (), Strtotime ()
Both of these methods can obtain the UNIX timestamp in PHP, Time () is directly obtained, Strtotime ($time, $now) to the time format to timestamp, $time is required. Clear this, want to know more, please continue to look down.
3. Date ($format) usage
Like what:
echo Date (' y-m-d '), Output: 2012-03-22
echo Date (' y-m-d h:i:s '), Output: 2012-03-22 23:00:00
echo Date (' y-m-d ', Time ()), Output: 2012-03-22 23:00:00 (results above, just one more timestamp parameter) (method of timestamp conversion to date format)
echo Date (' Y '). ' Year '. Date (' m '). ' Month '. Date (' d '). ' Day ', output: March 22, 2012
PHP Gets the current timestamp method