PHP - Add one week to a user defined date
You can try this
$start_date = "2015/03/02";
$date = strtotime($start_date);
$date = strtotime("+7 day", $date);
echo date('Y/m/d', $date);
Object Oriented Style using DateTime
classes:
$start_date = DateTime::createFromFormat('Y/m/d', $_POST['start_date']);
$one_week = DateInterval::createFromDateString('1 week');
$start_date->add($one_week);
$date_to_pay = $start_date->format('Y/m/d');
Or for those who like to have it all in one go:
$date_to_pay = DateTime::createFromFormat('Y/m/d',$_POST['start_date'])
->add(DateInterval::createFromDateString('1 week'))
->format('Y/m/d');
Please try the following:
date('d.m.Y', strtotime('+1 week', strtotime($start_date)));