zee000
03-17-2010, 10:16 AM
hi
i need a code to display the week no`s with dates as seen below for the present year..
week1 (01-07)
week2(08-15)
...week52or53(25-31)...
thanks in advance
BLiZZaRD
03-17-2010, 07:17 PM
Not exactly sure I follow what it is you want, but here are 2 tries:
<?php
echo "Week ";
echo date("W");
echo " Day ";
echo date("N");
?>
<br><br>
<?PHP
function week_day($month, $year, $current_day, $week_day_number=1){
$loop_start = $current_day-(date('N', mktime(0, 0, 0, $month, $current_day, $year))-1);//lets start loop from first day of week
$loop_end = $current_day+(7-(date('N', mktime(0, 0, 0, $month, $current_day, $year))));//lets end loop to last day of week
for($i = $loop_start; $i<=$loop_end; $i++){
$day_of_the_week = date('N', mktime(0, 0, 0, $month, $i, $year));//current day number 1-7 of week
$loop_date = date('d', mktime(0, 0, 0, $month, $i, $year));//current day in calendar
if($day_of_the_week == $week_day_number){//if weekday number equals day number then lets return date
return $loop_date;
}
}
}
echo week_day(8, 2009, 30, 1);//returns (24).08.2009
echo '<br>';
echo week_day(8, 2009, 30, 5);//returns (28).08.2009
?>
The firs gets the current week # and the current day of that week ( 1 - 7 )
The second part returns a numerical value for the given date. Examples shown return "24" and "28" respectively.
Perhaps you can draw off of these to get precisely what you want.
zee000
03-18-2010, 11:29 AM
sorry i have tried this but it does not reach my requirement
can u suggest any other.............
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.