Page 1 of 1

add 30 days to current date?

Posted: Sun Mar 25, 2007 4:20 am
by SmokyBarnable

Code: Select all

$now = time();
  $endtimefrom = gmdate('Y-m-d H:i:s', $now);
I would like to create a variable that is 30 days in the future based on $endtimefrom. What would be a good way?

Thank you.

Posted: Sun Mar 25, 2007 4:56 am
by stereofrog

Code: Select all

$future = strtotime("+30 days", $now);

Posted: Sun Mar 25, 2007 5:04 am
by SmokyBarnable
thanks!

:)

Posted: Sun Mar 25, 2007 12:59 pm
by Skara
or

Code: Select all

$now = time();
$later = time() + 60 * 60 * 24 * 30;
seconds * minutes * hours * days

Posted: Sun Mar 25, 2007 2:29 pm
by dreamscape
Skara wrote:or

Code: Select all

$now = time();
$later = time() + 60 * 60 * 24 * 30;
seconds * minutes * hours * days
But that is so ugly, and strtotime() makes code so much more readable :wink:

Posted: Mon Mar 26, 2007 1:31 am
by mikeq
You dont need the $now variable with strtotime

Code: Select all

$ThirtyDaysHence = strtotime("+30 days");