PHP 时间格式

在PHP  函数date  格式很多 重在形式

 

echo date('Y-m-d H:i:s', time());

 

输出的时间是: 2016-03-17 10:31:38

 

常用的一些对应的系统函数

字符串转换成时间戳:

strtotime

date()

然后就是一些活用的方法

echo date("Y-m-d");

// 昨天
echo date("Y-m-d",strtotime("-1 day"));
// 明天 
echo date("Y-m-d",strtotime("+1 day")); 
// 一周后
echo date("Y-m-d",strtotime("+1 week")); 
// 一周零两天四小时两秒后
echo ":".date("Y-m-d H:i:s",strtotime("+1 week 2 days 4 hours 2 seconds")); 
// 下个星期四
echo date("Y-m-d",strtotime("next Thursday")); 
// 上个周一
echo date("Y-m-d",strtotime("last Monday"); 
// 一个月前
echo date("Y-m-d",strtotime("last month");
// 一个月后
echo date("Y-m-d",strtotime("+1 month"); 
// 十年后
echo date("Y-m-d",strtotime("+10 year");

更多的,要自己去写了,我就不举例哈

 

posted @ 2016-03-17 10:38  方达达  阅读(226)  评论(0编辑  收藏  举报