php中挺好用的strtotime方法

  在PHP中, 網站推廣常常要對日期進行計算,好比要計算一個月前的日期,那麼其實最快的方法
是用strtotime,其功能很豐富,以下:

Java代碼   收藏代碼
  1. echo strtotime("now"), "\n";  
  2. echo strtotime("10 September 2000"), "\n";  
  3. echo strtotime("+1 day"), "\n";  
  4. echo strtotime("+1 week"), "\n";  
  5. echo strtotime("+1 week 2 days 4 hours 2 seconds"), "\n";  
  6. echo strtotime("next Thursday"), "\n";  
  7. 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)
相關文章
相關標籤/搜索