Re: correct date (cont.)
| From: | Richard Lynch | Date: | Thu, 09 Aug 2001 19:22:57 +0000 |
| Subject: | Re: correct date (cont.) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-62068@lists.php.net to get a copy of this message | ||
> This should get me exactly 3 months later and also checks for if its a
later
No, it won't on leap years, or during daylight savings time changes, etc.
Don't try to do the year/month calculation yourself.
Let PHP do it for you, and it will be correct. Every time.
$threemonths = mktim(0, 0, 0, date("m") + 3);
ACTUALLY, it would be even EASIER to use SQL to do this. Presumably MySQL
will let you use things not unlike...
where registation_date + '3 months' <= now()
You're probably better off storing a registration_date and an interval than
the deadline. Then, if you decide to extend everybody's 3 month freebie to
4 months, it's easy.
--
WARNING richard@zend.com address is an endangered species -- Use
ceo@l-i-e.com
Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm