How to determine whether the time format is in php

coldplay.xixi
Release: 2023-03-05 19:40:02
Original
7995 people have browsed it

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.

How to determine whether the time format is in php

[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; }
Copy after login

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() ] )
Copy after login

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 thephp trainingcolumn!

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!