<?php
$today = '2013-04-19';
//年
echo date("Y-m-d", strtotime($today."+3 year"));
//月
echo date("Y-m-d", strtotime($today."-1 month"));
//週
echo date("Y-m-d", strtotime($today."+10 week"));
//日
echo date("Y-m-d", strtotime($today."+10 day"));
//時
echo date("Y-m-d", strtotime($today."+2 hour"));
//分
echo date("Y-m-d", strtotime($today."+20 minute"));
//秒
echo date("Y-m-d", strtotime($today."+5 seconds"));
?>
混合使用範例
//加1天5秒注意事項:
echo date("Y-m-d", strtotime($today."+1 day 5 seconds"));
//加1週減2天
echo date("Y-m-d", strtotime($today."+1 week -2 day"));
若只有指定日期而未指定時間,默認日期當天00:00:00為時間。