Re: Date

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Monday 18 June 2007, Robert Cummings wrote:
> On Mon, 2007-06-18 at 21:57 -0400, Ron Piggott wrote:
> > If
> >
> > $expiry_date = "2007-10-17";
> >
> > How do I add 7 days to this?  I know the strtotime("+7 days"); command,
> > but don't know how to make it work with a date that isn't today.
>
> You would do:
>
>     strtotime( '+7 days', $time );
>
> The $time is a unix timestamp... so you'll need to convert $expiry_date
> to a unix timestamp. You can take a look at the mktime() function for
> more information.

Just be meta about it.

strtotime('+7 days', strtotime($expiry_date)); 

Ta da! :-)

(Note: strtotime() is probably not the fastest to execute way of doing it, but 
it's the fastest to write.  Choose wisely.)

-- 
Larry Garfield			AIM: LOLG42
larry@xxxxxxxxxxxxxxxx		ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux