在PHP中,
網站推廣常常要對日期進行計算,好比要計算一個月前的日期,那麼其實最快的方法
是用strtotime,其功能很豐富,以下:
- 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";
看到沒 +1 day +1 week,立刻求出1天后,1個星期後的日期了, 求1個月前,能夠: echo date('Y-m-d', strtotime('1 month ago')) 所以,判斷是否一個月前,能夠 if strtotime($my_date) < strtotime('1 month ago')) (fblww-0103)