note 100181 deleted from function.strtotime by derick
| From: | derick@php.net | Date: | Sun, 03 Nov 2013 15:20:07 +0000 |
| Subject: | note 100181 deleted from function.strtotime by derick | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-197404@lists.php.net to get a copy of this message | ||
Note Submitter: Nolan Grupe
----
If you're trying to make Saturday (or any other day for that matter) the first day of the week
to select datasets, here's a good workaround:
<?php
$last_sat=date("z", strtotime("last Saturday"));
$second_last_sat=date("z", strtotime("last Saturday-1 week"));
?>
then just query your database like so:
select everything since last saturday:
SELECT whatever.whatever from wherever WHERE DAYOFYEAR(complete) <= DAYOFYEAR(CURDATE()) AND
DAYOFYEAR(complete) > ".$last_sat."
the week before (beginning on a saturday):
SELECT whatever.whatever from wherever WHERE DAYOFYEAR(complete) <= ".$last_sat." AND
DAYOFYEAR(complete) > ".$second_last_sat."
Good luck!