Get time
1. Use the DATE function to format a local time.
Output Current Time
echo Date (' y-m-d h:i:s ');
2. Use the GETDATE function to get datetime information for the timestamp.
Print out detailed information
Var_dump (GETDATE (Time ()));
Time stamp
1. Use the time function to get the current timestamp
Output the current timestamp
Echo Time ()
2. Use the Mktime function to convert the datetime into a timestamp.
Parameters last, minute, second, month, day, year
Echo Mktime (10, 10, 10, 10, 10, 2005);
Time zone settings
1. Use the Date_default_timezone_get function to get the current time zone
Gets the default time zone of UTC
Echo Date_default_timezone_get ();
2. Use the Date_default_timezone_set function to set the current time zone
Set current time zone for Asia/Shanghai
Date_default_timezone_set (' Asia/shanghai ');
Time to output the current time zone
echo Date (' y-m-d h:i:s ')
Verify Date
1. Use the Checkdate function to verify.
Verification: Month, day, year is legal
Echo checkdate (15, 10, 2015)
Get more Time
1. Use the Gettimeofday function to get the current time
Output Schedule
Var_dump (Gettimeofday ());
2. Use the Strtotime function to convert the datetime into a timestamp.
Get timestamp by date time
echo strtotime (' 2015-10-10 10:10:10 ');
3. Use the Idate function to accept only one format string generation time.
Accept only one formatted string
echo idate (' Y ');
4. Use the Microtime function to get the timestamp and the number of microseconds.
Output microseconds and timestamps
Echo Microtime ();
PHP Date and time