# php如何输出6天前/1个月后的时间？

**URL:** <https://www.shiqidu.com/t/topic/227>\
**Category:** 问题求助\
**Tags:** 问与答\
**Created:** [2017 年10 月 1 日 04:24 UTC](https://www.shiqidu.com/t/topic/227 "2017-10-01T04:24:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

作者： ![shiqidu\_editor](https://www.shiqidu.com/user_avatar/www.shiqidu.com/shiqidu_editor/32/528_2.png) [@shiqidu\_editor](https://www.shiqidu.com/u/shiqidu_editor)\
发布日期： [2017 年10 月 1 日 04:24 UTC](https://www.shiqidu.com/t/topic/227/1 "2017-10-01T04:24:41Z")

</div>

rt

---

<div class="post-metadata">

作者： ![caojie](https://www.shiqidu.com/user_avatar/www.shiqidu.com/caojie/32/465_2.png) [@caojie](https://www.shiqidu.com/u/caojie)\
发布日期： [2017 年10 月 1 日 04:25 UTC](https://www.shiqidu.com/t/topic/227/2 "2017-10-01T04:25:18Z")

</div>

```php
// 6分钟前        
date('Y-m-d H:i:s',strtotime('-6 mins'))        
// 3小时前        
date('Y-m-d H:i:s',strtotime('-3 hours'))        
// 3天前        
date('Y-m-d H:i:s',strtotime('-3 days'))        
// 3个月前        
date('Y-m-d H:i:s',strtotime('-3 months'))        
// 1个月后        
date('Y-m-d H:i:s',strtotime('+1 month'))        
// 7天后        
date('Y-m-d H:i:s',strtotime('+7 days'))        
// 其实是有规律可寻的，xxx前 就用-负号加上xxx，如大于1xxx 加s【单位英文的复数形式】        
// 如果是xxx后，就用+加上xxx &gt;1 同样加s    

```
