note 23866 modified in ref.datetime by danbrown
| From: | danbrown@php.net | Date: | Sun, 20 Jul 2008 02:27:59 +0000 |
| Subject: | note 23866 modified in ref.datetime by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-141962@lists.php.net to get a copy of this message | ||
I wanted to find all records in my database which match the current week (for a call-back function).
I made up this function to find the start and end of the current week :
<?php
function week($curtime) {
$date_array = getdate (time());
$numdays = $date_array["wday"];
$startdate = date("Y-m-d", time() - ($numdays * 24*60*60));
$enddate = date("Y-m-d", time() + ((7 - $numdays) * 24*60*60));
$week['start'] = $startdate;
$week['end'] = $enddate;
return $week;
}
?>
--was--
I wanted to find all records in my database which match the current week (for a call-back function).
I made up this function to find the start and end of the current week :
function week($curtime) {
$date_array = getdate (time());
$numdays = $date_array["wday"];
$startdate = date("Y-m-d", time() - ($numdays * 24*60*60));
$enddate = date("Y-m-d", time() + ((7 - $numdays) * 24*60*60));
$week['start'] = $startdate;
$week['end'] = $enddate;
return $week;
}
http://php.net/manual/en/ref.datetime.php