note 7772 deleted from function.mktime by vincent

From: Date: Wed, 10 Sep 2003 19:10:30 +0000
Subject: note 7772 deleted from function.mktime by vincent
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-56014@lists.php.net to get a copy of this message
Note Submitter: robert.jackson@utoronto.ca ---- 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 (#56014) next »