Adding three months to a date in PHP

前端 未结 9 1140
我寻月下人不归
我寻月下人不归 2020-12-02 13:03

I have a variable called $effectiveDate containing the date 2012-03-26.

I am trying to add three months to this date and have been unsu

9条回答
  •  醉酒成梦
    2020-12-02 13:33

    Add nth Days, months and years

    $n = 2;
    for ($i = 0; $i <= $n; $i++){
        $d = strtotime("$i days");
        $x = strtotime("$i month");
        $y = strtotime("$i year");
        echo "Dates : ".$dates = date('d M Y', "+$d days");
        echo "
    "; echo "Months : ".$months = date('M Y', "+$x months"); echo '
    '; echo "Years : ".$years = date('Y', "+$y years"); echo '
    '; }

提交回复
热议问题