Re: Date Help Needed
| From: | Jason Barnett | Date: | Mon, 31 Jan 2005 17:27:57 +0000 |
| Subject: | Re: Date Help Needed | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-25492@lists.php.net to get a copy of this message | ||
Ron Herhuth wrote:
I am trying to construct a function where I feed it a number such as "x" it returns the date "x" days ago.<?php $format = 'l dS of F Y h:i:s A'; /** Check that "now" relative time is ok, instead of midnight */ echo date($format, strtotime("now")) . "\n"; /** If now resolves correctly, then this should work */ $x = strtotime("-1 days"); echo date($format, $x); ?>
I tried checking out several resources that give you the difference between two dates, but not exactly what I was looking for. I was just hoping someone had a little algorithm in their bag of tricks. Thanks, Ron-- Teach a man to fish... NEW? | http://www.catb.org/~esr/faqs/smart-questions.html STFA | http://marc.theaimsgroup.com/?l=php-general&w=2 STFM | http://www.php.net/manual/en/index.php STFW | http://www.google.com/search?q=php LAZY | http://mycroft.mozdev.org/download.html?name=PHP&submitform=Find+search+plugins