不需要外部库。 PHP已经胜任了这一切。
<?php
/** These examples work with the current time **/
echo strtotime("now"), "\n";
echo strtotime("10 September 2000"), "\n";
echo strtotime("+1 day"), "\n";
echo strtotime("+1 week"), "\n";
echo strtotime("+1 week 2 days 4 hours 2 seconds"), "\n";
echo strtotime("next Thursday"), "\n";
echo strtotime("last Monday"), "\n";
/** This is a made up time **/
$lessMonth = strtotime("06/19/1986 3:00PM")
$lessMonth = strtotime("-1 month", $lessMonth);
echo $lessMonth, "\n";
echo gmdate('c', $lessMonth);
/** 86 400 seconds in a day */
$daysBetween = (strtotime("now") - $lessMonth)/86400
?>
谢谢,我只知道strtotime。:) strtotime很好,但没有像daysBetween,weeksBetween,monthsBetween之类的函数。约达有我需要扮演的日期。 – nightingale2k1 2009-08-25 08:59:16