如何在PHP中获得15天/ 1个月的日期? [英] How can I get a date after 15 days/1 month in PHP?

查看:206
本文介绍了如何在PHP中获得15天/ 1个月的日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的PHP代码中,我的变量$ postedDate中有一个日期。

现在我想在7天,15天,1个月和2个月之后获取日期。 p>

我应该使用哪个日期功能?



输出日期格式应为美国格式。

解决方案

使用strtotime。

  $ newDate = strtotime ('+15天',$ date)

$ newDate现在将在$ date后15天。 $ date是unix时间。



http:// uk。 php.net/strtotime


In my PHP code I have a date in my variable "$postedDate".
Now I want to get the date after 7 days, 15 days, one month and 2 months have elapsed.

Which date function should I use?

Output date format should be in US format.

解决方案

Use strtotime.

$newDate = strtotime('+15 days',$date)

$newDate will now be 15 days after $date. $date is unix time.

http://uk.php.net/strtotime

这篇关于如何在PHP中获得15天/ 1个月的日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆