Having problems adding 1 month to a variable from a database trying numerous methods given on the forum:
$row["pchargedate"] returns 2018-03-01
$newduedate = date('Y-m-d', strtotime('+1 month', $row["pchargedate"])) ;
-returns 0000-00-00
$newduedate = date('Y-m-d', strtotime('+1 month', $row["pchargedate"])) ; }
$newduedate = date ( 'Y-m-d' , $newduedate );
- returns 1970-01-01
$duedate = DateTime::createFromFormat('Y-m-d', $row["pchargedate"]);
$duedate = $duedate->format('d-m-Y');
if ($row["pchargedate"] == '1' ) { $newduedate = strtotime ( '+1 month' , strtotime ( $pchargedate ) ) ; }
$newduedate = date ( 'Y-m-d' , $newduedate );
- $duedate returns 01-03-2018 but $newduedate is 1970-01-01
Any help much appreciated.