2013年11月14日 星期四

【php】時間相關

時間加減
$date = date("Y-m-d",strtotime("-5 day")); // 今天日期減5天
$date = date("Y-m-d",strtotime("-5 month")); // 今天日期減5個月
$date = date("Y-m-d",strtotime("-5 year")); // 今天日期減5年

設定某個變數時間加減
$date = date("Y-m-d",strtotime("+10 day",strtotime($start_date))); // $start_date + 10天

怕系統時間不是台灣時間,確保安全程式可以加上
ini_set('date.timezone','Asia/Taipei');

沒有留言:

張貼留言