Re: Adding X days to a time string...
| From: | joel boonstra | Date: | Fri, 21 Nov 2003 16:20:36 +0000 |
| Subject: | Re: Adding X days to a time string... | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-170592@lists.php.net to get a copy of this message | ||
On Fri, Nov 21, 2003 at 11:15:20AM -0500, Jeff Lewis wrote:
> Sorry, I may have muddled that...the issue isn't converting a string to
> a time, it's taking a time (1026360000 for example) and adding 30 days
> to that.
Ah, but it is an issue of converting a string to a time. strtotime()
can "Parse about any English textual datetime description into a UNIX
timestamp". It also has a handy optional parameter telling you when to
consider "now". So to add thirty days to "now" (1026360000 in your
example):
<?php
$now = however_you_get_your_timestamp();
$future = strtotime('+30 days', $now);
?>
Such a handy function -- no need to worry about leap years, number of
days in a month, etc...
--
[ joel boonstra | gospelcom.net ]