Re: Simple date question
| From: | David Nicholson | Date: | Wed, 30 Jul 2003 18:33:47 +0000 |
| Subject: | Re: Simple date question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-157566@lists.php.net to get a copy of this message | ||
Hello,
This is a reply to an e-mail that you wrote on Wed, 30 Jul 2003 at
19:18, lines prefixed by '>' were originally written by you.
> If I have:
> $firstdate = "2003-06-28";
> then how can I get $firstdate plus 4 days?
> Thanks!
date("Y-d-m",mktime(0,0,0,substr($firstdate,5,2),substr($firstdate,8,2),substr($firstdate,0,4))
+ (60*60*24*4));
Should do the trick, you can probably use strtotime instead of all
the substr()'s but at a guess I would expect the above to be quicker
(not that I have benchmarked it).
HTH
David.
--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/
Professional Web Development by David Nicholson
http://www.djnicholson.com/
QuizSender.com - How well do your friends actually know you?
http://www.quizsender.com/
(developed entirely in PHP)