note 9108 added to getdate
| From: | ih2 at morton-fraser dot com | Date: | Tue, 17 Oct 2000 09:01:12 +0000 |
| Subject: | note 9108 added to getdate | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-6560@lists.php.net to get a copy of this message | ||
To do comparisons on dates stored in mysql db against 7 days ago, 1 month ago etc use the following:
$last_week = date("Y-m-d", mktime(0,0,0, date(m), date(d)-7,date(Y)));
if($date > $last_week)
{
etc.
This allows for intelligent looping i.e. works at start/end of month/year
I have noticed other postings re this and they have not worked for me.Hope this helps.
http://www.php.net/manual/function.getdate.php