strtotime — Parse about any English textual datetime description into a Unix timestamp
Datetime to Timestamp
$timestamp = strtotime($datetime);
Timestamp to Datetime
date('Y-m-d', $timestamp);
<?php // Calculate the difference in days. $date1 = strtotime(2010-10-10); $date2 = strtotime(2011-12-01); $daysDiff = ($date2 - $date1)/(24 * 60 * 60); // Which is the latest? if ($date2 > $date1) { echo "$date2 is later than $date1"; } ?>
可以用以上Code來作時間前後的比較, But if you do, your code will be susceptible to the 2038 bug.