PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
SmokyBarnable
Forum Contributor
Posts: 105 Joined: Wed Nov 01, 2006 5:44 pm
Post
by SmokyBarnable » Sun Mar 25, 2007 4:20 am
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.
Skara
Forum Regular
Posts: 703 Joined: Sat Mar 12, 2005 7:13 pm
Location: US
Post
by Skara » Sun Mar 25, 2007 12:59 pm
or
Code: Select all
$now = time();
$later = time() + 60 * 60 * 24 * 30;
seconds * minutes * hours * days
dreamscape
Forum Commoner
Posts: 87 Joined: Wed Jun 08, 2005 10:06 am
Contact:
Post
by dreamscape » Sun Mar 25, 2007 2:29 pm
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
mikeq
Forum Regular
Posts: 512 Joined: Fri May 03, 2002 3:33 am
Location: Edinburgh, Scotland
Post
by mikeq » Mon Mar 26, 2007 1:31 am
You dont need the $now variable with strtotime
Code: Select all
$ThirtyDaysHence = strtotime("+30 days");