PHP 抓昨天的日期

date("Y/m/d", mktime(0, 0, 0, date('m'), date('d')-1, date('Y')));
or
date("Y/m/d", time()-24*3600);
or
date("Y/m/d", strtotime('-1 day'));


PHP 抓下個月的日期

date("Y/m/d", mktime(0, 0, 0, date('m')+1, date('d'), date('Y')));
date("Y/m/d", strtotime('+1 month'));

 

個人覺的strtotime比較好用
strtotime可用的參數如下,只列出部份

day month year hours days seconds week now .....
(next Thursday) (last Monday)

 

 

 

 

 

文章標籤
全站熱搜
創作者介紹
創作者 Ching-Wei 的頭像
Ching-Wei

Ching Wei : This is My Life - 工作、攝影、旅遊

Ching-Wei 發表在 痞客邦 留言(0) 人氣(537)