0

the following code gives first date of week for the given date range. how to get week number from the date??? thanks.

<?php
$start = $week = strtotime('2011-01-01'); 
$end = strtotime('2011-02-01'); 
while($week < $end) {     
echo date('Y-m-d',$week), PHP_EOL;
//echo week num???      
$week = strtotime("+1 week", $week); 
}
?>
1
Contributor
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Ichcha
0

i solved it.. :)

<?php
$start = $week = strtotime('2011-01-01');
$end = strtotime('2011-02-01'); 
$year= date('Y ', $week);
$Jan1 = gmmktime(0, 0, 0, 1, 1, $year); 
while($week < $end) {     
echo date('Y-m-d',$week), PHP_EOL;
echo (int)(($week - $Jan1) / (7 * 24 * 60 * 60)) + 1, PHP_EOL;    
$week = strtotime("+1 week", $week); }
?>
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.