my second question about dates. I have a given week and year. Now I want the
dates of all days in that week. Let say week 15, year 2009 (starts on
monday). So

monday = 06-april-2009
...
sunday = 12-april-2009

this is the code I have to calculate that. Is it possible to do with Zend
Date?

$week = 15;
$year  = 2009;

// Get a random monday in the requested year
$iRandomDate = mktime(0, 0, 0, 3, 1, $year);
// What's the first monday before this random date?
$iMonday = mktime(0, 0, 0, date('n', $iRandomDate), date('j',
$iRandomDate)-(date('w', $iRandomDate)-1), $year);
// Get the date of week 1
$iFirstWeek = mktime(0, 0, 0, date('n', $iMonday), date('j', $iMonday) -
7*(date('W', $iMonday)-1), $year);
$datefromweek = mktime(0, 0, 0, date('n', $iFirstWeek), date('j',
$iFirstWeek) + 7*($week-1), date('Y', $iFirstWeek));

for ($i = 0; $i < 7; $i++) {
  $days[] = date('Y-m-d', $datefromweek);
  $datefromweek = $datefromweek + 86400;
}


-----
visit my website at  http://www.phpscriptor.com/ http://www.phpscriptor.com/ 
-- 
View this message in context: 
http://www.nabble.com/Getting-dates-from-given-week.-tp22988727p22988727.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to