【问题标题】:how will i take future months by the given month and year in php我将如何在 php 中按给定月份和年份计算未来几个月
【发布时间】:2015-09-21 07:32:16
【问题描述】:
 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;

【问题讨论】:

  • 似乎是一个不错的项目。如果您在尝试实施时发现任何错误,请告诉我们,以便我们为您提供帮助!
  • 不知道插入的sql查询。

标签: php datetime monthcalendar


【解决方案1】:

你可以试试这个代码

假设用户输入这个日期

$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)));

【讨论】:

    猜你喜欢
    • 2016-11-23
    • 1970-01-01
    • 1970-01-01
    • 2011-06-20
    • 1970-01-01
    • 2022-01-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多