date() and mktime() functions: weeknumbers and months.
| From: | Davy Obdam | Date: | Mon, 31 Mar 2003 14:07:18 +0000 |
| Subject: | date() and mktime() functions: weeknumbers and months. | ||
| Groups: | php.db php.general php.windows | ||
| Request: | Send a blank email to php-db+get-26741@lists.php.net to get a copy of this message | ||
Hi people,
I would like to select news from my database bases on week/year and
month/year.
How can i do this.. I would like to pass two arguments in the query
string, like news.php?week=14&year=2003 or news.php?month=3&year=2003.
Can anybody help me.. Thanks in advance. I have been looking at the
date() and mktime() functions, but is there anyway to determine the date
from a weeknumber? I have been using this:
$yr="2003";
$mnth="03";
$dy="31";
echo "base date: ".$yr."-".$mnth."-".$dy."<br />";
echo "last sunday: ".date("Y-m-d",
mktime(0,0,0,$mnth,$dy-date("w",mktime(0,0,0,$mnth,$dy,$yr)),$yr))."<br
/>";
echo "next saturday: ".date("Y-m-d",
mktime(0,0,0,$mnth,$dy+6-date("w",mktime(0,0,0,$mnth,$dy,$yr)),$yr))."<b
r />";
$sql = "SELECT * FROM news WHERE date>='$last_sunday' AND
date<='$next_saturday').
But i would find it better to use a weeknumber instead
Best regards,
Davy Obdam - Networking4all
Webapplication developer
E-mail: d.obdam@networking4all.com
Web: http://www.networking4all.com
Kijk ook eens op: http://www.verzamelgids.nl