1.time这个返回当前时间戳
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
2.strtotime()根据字符串得到一个时间戳,更直观些相比用time()的计算表达式
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
这2个等价的。
如下使用
1.)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
结果:
7天前:2008-09-22
今天:2008-09-29
7天后2008-10-06
今天:2008-09-29
7天后2008-10-06
或者用这个也行:
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
n周前后:
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
2.)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/265ea94768f0da2ec7f59345f7b83d1c.png)
输出:
103天之后是:2009-01-10
下周三:2008-10-01
下周三:2008-10-01