php pdo代码从表中选择日期并在所选日期添加+ 1个月

table name - receipt_entry

column name - startingdate

I need to select startingdate from receipt_entry table and add + 1 month in selected date and display in another date textbox.

For EX -

startingdate = 23-02-2015 then display 23-03-2015 in date textbox.

this function works on selected event changed of listbox...

Every thing is working in my code except this date textbox..not getting proper date....this display wrong date in my textbox..

**Index.php page** 

     <!--AUTO POPULATE TEXTBOX ON COMBOBOX CHANGED EVENT START -->
       <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js" type="text/javascript"></script>
    <script>
    function showUser(str)
    {
    if (str=="")
    {
        document.getElementByName("cityname").value="";
        return;
    }
    if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
    }
    else
    {// code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
            var data = JSON.parse(xmlhttp.responseText);
            for(var i=0;i<data.length;i++) 
            {               
                document.getElementById("generateddate").value = data[i].date;
            }
        }
    }
    xmlhttp.open("GET","coupondata.php?q="+str,true);
    xmlhttp.send();
    }
    </script>
     <!--AUTO POPULATE TEXTBOX ON COMBOBOX CHANGED EVENT ENDS -->


    <select class="special-flexselect"  name="coupon" tabindex="1" onChange="showUser(this.value)">                 
                            <option  value="" ></option>                        
                             <?php foreach ($loadcoupon as $coup){ ?>   
                                <option  value="<?php echo $coup["coupon"]; ?>"><?php echo $coup["coupon"]; ?></option>
                            <?php }?>
                            </select>

<input type="text" name="generateddate" id="generateddate"  value="" class="field size4" />

coupondata.php page

  <?php
    require_once('includes/config.php');
    $q = $_GET['q'];
    $city = $database->getRows("SELECT * FROM receipt_entry WHERE coupon = :coupon", array(':coupon'=>"$q"));  
    $info = array();
    foreach($city as $row)
    {    
        $startingdate = $row['startingdate'];   
        $generateddate = date("d-m-Y", strtotime($startingdate . " +" . " MONTHS"));    
        //$generateddate = date("d-m-Y", strtotime($startingdate) . " + MONTHS");

        $cWeb[] = $row['customer_name'];
        $receipt = $row['receipt_no'];
        $book = $row['book_no'];
        $booking = $row['bookingdate'];      
        $info[] = array('web' => $cWeb,'rec' =>$receipt,'book' =>$book,'booking' =>$booking,'date' =>$generateddate );
    }
    echo json_encode($info);
    ?> 

You need to tell how many months you'd like to add, php doesn't know that by default

    $generateddate = date("d-m-Y", strtotime($startingdate . " + 1 MONTHS"));    
$generateddate = date("d-m-Y", strtotime("$startingdate + 1 MONTH"));

Need To add months number ...how many months you want to add.

 <?php
    require_once('includes/config.php');
    $q = $_GET['q'];
    $city = $database->getRows("SELECT * FROM receipt_entry WHERE coupon = :coupon", array(':coupon'=>"$q"));  
    $info = array();
    foreach($city as $row)
    {    
        $startingdate = $row['startingdate'];   
        $generateddate = date("d-m-Y", strtotime($startingdate . " +" . " 1MONTHS"));   
        //$generateddate = date("d-m-Y", strtotime($startingdate) . " + MONTHS");

        $cWeb[] = $row['customer_name'];
        $receipt = $row['receipt_no'];
        $book = $row['book_no'];
        $booking = $row['bookingdate'];      
        $info[] = array('web' => $cWeb,'rec' =>$receipt,'book' =>$book,'booking' =>$booking,'date' =>$generateddate );
    }
    echo json_encode($info);
    ?>