php 时间转化总结

iQuery插件datepicker获取的时间函数为"月月/天天/年年年年"(以04/21/2015为例)的形式
(1)转化为2015-21-04形式:$start = date('Y-m-d',strtotime($start1));
(2)计算两个时间所差天数:$days=floor((strtotime($end)-strtotime($start))/86400);
(3)求所求日期的下一天:$nextday=date("Y-m-d",strtotime("$tday +1 day"));
(4)求所求日期的一周后:$nextweekday=date("Y-m-d",strtotime("$tday+1 week"));
(5)求下个星期二:date("Y-m-d",strtotime("next Thursday"));
(6)上个周一: date("Y-m-d",strtotime("last Monday"));
(7)一个月前: date("Y-m-d",strtotime("last month"));
(8)一个月后: date("Y-m-d",strtotime("+1 month"));

posted @ 2015-04-21 10:28  nolonely  阅读(196)  评论(0编辑  收藏  举报