Home>Article>Backend Development> How to convert date to timestamp in php
You can use the strtotime function in PHP to convert date into a timestamp, because the strtotime function is used to parse the date or time description of any English text into a Unix timestamp. The syntax is "strtotime(time,now) );".
Recommended: "PHP Tutorial"
php date to timestamp
date('Y-m-d H:i:s', 1156219870);
1. Use function to convert UNIX timestamp to date: date()
General form: date('Y-m-d H:i:s', 1156219870);
2. Use function to convert date to UNIX timestamp: strtotime()
General form: strtotime('2010-03-24 08:15 :42');
strtotime() function parses the date or time description of any English text into a Unix timestamp
3. This method completes the conversion in the PHP program. The advantage is that no matter Whether the data obtained by querying in the database can be converted, the conversion range is not limited. The disadvantage is that it takes up the parsing time of the PHP parser and is relatively slow.
##
The above is the detailed content of How to convert date to timestamp in php. For more information, please follow other related articles on the PHP Chinese website!