I got to ask...
I typed in the below from what is above and got 23 for january 2004, but when i look on my trusty wall planner its 22.
Am i missing something here?
<?
//Determine the first day of the month
$first_timestamp=mktime(0, 0, 0, $period, 1, $year);
$first_day_month=date("z",$first_timestamp);
$first_rx30_day=($first_day_month+1);
echo "First Timestamp $first_timestamp<BR>";
echo "First PHP day of month value: $first_day_month <br>"; //REMOVE FOR PRODUCTION
echo "First Rx30 of month value: $first_rx30_day <br>"; //REMOVE FOR PRODUCTION
//Determine the last day of the month
$last_timestamp = mktime(0, 0, 0, $period);
$last_day_month=date("t",$last_timestamp);
$last_rx30_day=($first_rx30_day+$last_day_month-1);
//$end_timestamp= mktime(0, 0, 0, $period, $last_day_month, $year);
$end_timestamp= mktime(24, 0, 0, $period, $last_day_month, $year, -1);
echo "Number days in month value: $last_day_month <br>"; //REMOVE FOR PRODUCTION
echo "Last rx30 day of month value: $last_rx30_day <br>"; //REMOVE FOR PRODUCTION
//Define the end and begin dates
$begindate=$first_timestamp;
$enddate=$end_timestamp;
//Loop through PHP Datestamps for # weekdays
$workdays=0; //sets the count to zero
$testdate=$begindate; //set the test date to the first date
while($testdate <= $enddate) //begin the while loop
{
if (date("D", $testdate)=='Mon') //Check for mondays
{$workdays++;}
if (date("D", $testdate)=='Tue') //Check for tuesdays
{$workdays++;}
if (date("D", $testdate)=='Wed') //Check for wednesdays
{$workdays++;}
if (date("D", $testdate)=='Thu') //Check for thursdays
{$workdays++;}
if (date("D", $testdate)=='Fri') //Check for fridays
{$workdays++;}
$testdate=($testdate+86400);
}
echo "Weekdays in month = $workdays";
?>
Can someone tell me whats wrong with this?