In PHP, the date can be converted into a timestamp through the strtotime function. The conversion syntax is such as "strtotime(time,now);", where the parameter time specifies the date or time string, and the parameter now specifies the calculation Returns the timestamp of the value.
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
Function used to convert date to UNIX timestamp: strtotime()
General form: strtotime('2010-03-24 08:15:42');
strtotime() function converts the date or time of any English text The description resolves to a Unix timestamp (number of seconds since January 1 1970 00:00:00 GMT).
Note: If the year representation uses a two-digit format, values 0-69 will be mapped to 2000-2069, and values 70-100 will be mapped to 1970-2000.
Note: Please note that for dates in m/d/y or d-m-y format, if the separator is a slash (/), the American m/d/y format is used. If the delimiter is a dash (-) or a dot (.), the European d-m-y format is used. To avoid potential errors, you should use YYYY-MM-DD format whenever possible or use the date_create_from_format() function.
Syntax
strtotime(time,now);
Parameters
time is required. Specifies a date/time string.
now Optional. Specifies the timestamp used to calculate the return value. If this parameter is omitted, the current time is used.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of Convert php date to timestamp. For more information, please follow other related articles on the PHP Chinese website!