bhakti_thakkar
10-27-2006, 10:47 AM
hi,
how can i get total weekends falling in the current year:confused:
Thanks
Bhakti Thakkar
how can i get total weekends falling in the current year:confused:
Thanks
Bhakti Thakkar
|
||||
finding total weekends for the current yearbhakti_thakkar 10-27-2006, 10:47 AM hi, how can i get total weekends falling in the current year:confused: Thanks Bhakti Thakkar mlseim 10-27-2006, 02:31 PM The best I could come up with ... But you need to really define what a weekend is. Both Saturday and Sunday, or count one of those days as a weekend? Same with days, 01/01/2006 --> 12/31/2006 or 01/01/2006 --> 01/01/2007 How you specify one year could end up adding 1 extra weekend. It all depends on how you look at it. <?php $date1="01/01/2006"; $date2="12/31/2006"; $days_between=dateDiff("/", $date2, $date1); $weekends=$days_between/7; echo "Days Between Dates: $days_between"; echo "<br><br>"; echo "Weekends: $weekends"; function dateDiff($dformat, $endDate, $beginDate) { $date_parts1=explode($dformat, $beginDate); $date_parts2=explode($dformat, $endDate); $ts1=mktime(0, 0, 0, $date_parts1[0], $date_parts1[1], $date_parts1[2]); $ts2=mktime(0, 0, 0, $date_parts2[0], $date_parts2[1], $date_parts2[2]); $difference = $ts2-$ts1; $diffday = $difference/86400; $startday=date(w,$ts1); //day of week $endday=date(w,$ts2); //day of week // do some calculations here on whether or not the first day is // Sunday (therefore, considered a full weekend? // You'll have to determine what you want to count as a weekend. // (Sunday=0, Saturday=6) // Same with the last day, what if Dec 31 is a Saturday? return $diffday; } ?> |
| |||
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum