How PHP determines whether it is a time format: You can determine it through the strtotime() function. The syntax of the strtotime() function is: [int strtotime (string $time [,int $now = time()])]. If successful, the timestamp will be returned. If failed, FALSE will be returned.
[Related learning recommendations: php programming (video)]
How to determine whether it is a time format in php:
You can use the strtotime function to determine whether it is a time format
function isDateTime($dateTime){ $ret = strtotime($dateTime); return $ret !== FALSE && $ret != -1; }
strtotime function usage is as follows:
strtotime parses the date and time description of any English text into a Unix timestamp
int strtotime ( string $time [, int $now = time() ] )
This function is expected to accept a string containing the United States A string in English date format and attempts to parse it into a Unix timestamp (number of seconds since January 1 1970 00:00:00 GMT) relative to the time given by the now parameter, or if this parameter is not provided. The current system time.
time: date/time string
now: timestamp used to calculate the return value
Return value:
Returns the timestamp if successful, otherwise returns FALSE; before PHP 5.1.0, this function returned -1 on failure.
If you want to know more about programming learning, please pay attention to the php training column!
The above is the detailed content of How to determine whether the time format is in php. For more information, please follow other related articles on the PHP Chinese website!