My shared hosting package at 1and1 only includes PHP 5.2.17 — so I can’t use the DateTime object. Very annoying!
I currently have this code
$eventDate = new DateTime('2013-03-16'); // START DATE
$finishDate = $eventDate->add(new DateInterval('P'.$profile["Weeks"].'W'));
But obviously it won’t work.
How can do I the same with code that will work with PHP5.2? (The code adds X number of weeks to a particular date.)
Just get the timestamp with strtotime() and add x * seconds of a week
or what I’ve just found out:
Alternatively you can utilize the
DateTimeclass. Use the the methodmodifyto change your date (like instrtotime):