我将如何在PHP中给定月份和年份的未来月份

时间:2015-09-21 07:32:16

标签: php datetime monthcalendar

 INSERT:<input type="text" name="my">
    no of months:<input type="text" name="noofmonths">
<input type="submit" name="sub" value="submit">

点击提交按钮,我想要相应的未来月/年。

Eg:INSERT: Septemeber 2015;
no of months:4;

i want an o/p:January 2016;

另一个例如:

Eg:INSERT: December 2015;
no of months:2;

i want an o/p:February 2016;

1 个答案:

答案 0 :(得分:0)

您可以尝试此代码

假设用户输入此日期

$date = "20 September";  //Your spelling for September is wrong make sure user enter correct spelling

用户每月输入4个

echo $effectiveDate = date('F Y', strtotime("+4 months", strtotime($date)));