Alex Rivera | Logout

php get future date time

Asked 2010-04-09T06:21:52.743
19

I don't know how to explain this correctly but just some sample for you guys so that you can really get what Im trying to say.

Today is April 09, 2010

7 days from now is April 16,2010

Im looking for a php code, which can give me the exact date giving the number of days interval prior to the current date.

I've been looking for a thread which can solve or even give a hint on how to solve this one but I found none.

Edit
Report

1 Answer

37

If you are using PHP >= 5.2, I strongly suggest you use the new DateTime object, which makes working with dates a lot easier:

<?php
$date = new DateTime("2006-12-12");
$date->modify("+7 day");
echo $date->format("Y-m-d");
?>
answered 2010-04-09T06:38:07.477

Your Answer