note 7773 deleted from function.date by jimw

From: Date: Fri, 02 Nov 2001 00:41:32 +0000
Subject: note 7773 deleted from function.date by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-20049@lists.php.net to get a copy of this message
I had to make a MySQL query for a given week (i.e. SELECT...WHERE date>='$last_sunday' AND date<='$next_saturday'). The php code I came up with is illustrated by: $yr="2000"; $mnth="03"; $dy="02"; echo "base date: ".$yr."-".$mnth."-".$dy."&lt;br>"; echo "last sunday: ".date("Y-m-d", mktime(0,0,0,$mnth,$dy-date("w",mktime(0,0,0,$mnth,$dy,$yr)),$yr))."&lt;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))."&lt;br>"; This seems to work within a month, across months (including leap years), and across years.

« previous php.notes (#20049) next »