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.
echo date("Y-m-d", strtotime("+10 days", strtotime($start_date))); You try like above. Replace from "+10 days" to your desired value to get the number of days added as you wish.
echo(strtotime("next Monday") . "<br>"); echo(strtotime("last Sunday"));
The date_add() function adds some days, months, years, hours, minutes, and seconds to a date.
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");
?>
Take a look here - http://php.net/manual/en/function.strtotime.php
<?php
// This is what you need for future date from now.
echo date('Y-m-d H:i:s', strtotime("+7 day"));
// This is what you need for future date from specific date.
echo date('Y-m-d H:i:s', strtotime('01/01/2010 +7 day'));
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With