Re: Date
| From: | Larry Garfield | Date: | Tue, 19 Jun 2007 03:22:56 +0000 |
| Subject: | Re: Date | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-257364@lists.php.net to get a copy of this message | ||
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@garfieldtech.com 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