Because $now+(7*24*60*60) isn't very intuitive to a human. Why would you do it that way instead of:
$days = 24*60*60; $now = time(); $plus7 = $now+(7*$days); echo 'Current Date: '.date('Y-m-d', $now); echo 'Date in 7 days: '.date('Y-m-d', $plus7); Maybe you think like a machine, but the way I did it avoids the whole *24*60*60 nonesense that just makes the code seem cluttered to me. And what happens if I make a typo and do *70 or *25? I've made plenty of typos in my day and I'm sure everyone else has. Why risk a slight miscalculation that could give you inaccurate results when PHP is happy to help? Maybe you'd say, "What if you mistype the 7 as a 9?" well, then I'm screwed either way. But I've gone from 4 potential typo problems to one. Sounds like a good improvement to me. This is mostly a matter of style. Your way works as well as mine. I just like mine better. People can decide which way they'd prefer. Your example is good to help people realize how they can manually do the calculations if they should need to though, so thanks for posting it! -TG > -----Original Message----- > From: M. Sokolewicz [mailto:[EMAIL PROTECTED] > Sent: Friday, September 10, 2004 4:08 PM > To: [EMAIL PROTECTED] > Subject: Re: [PHP] Adding +7 more days on date() value problem > > > Why would you do such strange things? It's a lot more simple :P > > $now = time(); > $plus7 = $now+(7*24*60*60); // 7 days, containing 24 hours each, > containing 60 minutes each, containing 60 seconds each. > > echo 'Current Date: '.date('Y-m-d', $now); > echo 'Date in 7 days: '.date('Y-m-d', $plus7); > > now isn't that easier ;) > > Trevor Gryffyn wrote: > > > I disagree on the strtotime recommendations that everyone else gave. > > The mktime() function itself will compensate for leap > years, "day = 36" > > type stuff and all of that. > > > > <?php > > $curdate = date("Y-m-d"); > > $plus7 = > date("Y-m-d",mktime(0,0,0,date("m"),date("d")+7,date("Y"))); > > Echo "Current Date: $curdate<br>"; > > Echo "+7 Dats Date: $plus7"; > > ?> > > > > > > Simple as that! > > > > -TG > > > > > >>-----Original Message----- > >>From: Louie Miranda [mailto:[EMAIL PROTECTED] > >>Sent: Tuesday, July 27, 2004 11:31 PM > >>To: [EMAIL PROTECTED] > >>Subject: [PHP] Adding +7 more days on date() value problem > >> > >> > >>I can't figure how could i add +7 more days on the DD (Day) > value. My > >>problem is, when the day is close on the end of the month like > >> > >>07/29/2004 > >> > >>when i add +7 on 29 = 36, its obvious we dont have 36 on > the calendar. > >>And im creating a program below, to explode it and maybe just add +. > >>But i think its useless if im just going to do + on the DD (Day) > >>value. > >> > >>Hmm :? > >> > >>## > >><?php > >>$curdate = date("Y-m-d"); > >>$plus7 = explode("-", $curdate); > >> > >>print (" > >><p>cut: > >>" .$plus7[0]. " > >>" .$plus7[1]. " > >>" .$plus7[2]. " > >></p> > >> > >>Current Date: $curdate<br> > >>+7 Dats Date: $plus7 > >> > >>"); > >>?> > >>## > >> > >>-- > >>Louie Miranda > >>http://www.axishift.com > >> > >>-- > >>PHP General Mailing List (http://www.php.net/) > >>To unsubscribe, visit: http://www.php.net/unsub.php > >> > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php