I created a class named Date_Helper.class.php that would handle all my date tasks for me. My very first function was supposed to generate a list of dates in MySQL format for all the weekdays between a start date and an end date. All I get is 1969-12-31, which I assume is the base date for PHP. I've (1) pulled public off the function descriptor so it will run outside the class and (2) commented out the looping part of the function so you won't get stuck running an infinite loop generated by the wrong date data.
Can anyone see what I'm doing wrong with mktime or date?
function generateList_weekdays ( $month1, $date1, $year1, $month2, $date2, $year2 )
{
$rawCurrentDate = mktime( 0, 0, 0, $month1, $date1, $year1 );
$sqlCurrentDate = date( "Y m j", $rawCurrentDate );
echo "Start Date: ".$sqlCurrentDate."<br />";
$rawEndDate = mktime( 0, 0, 0, $month2, $date2, $year2 );
$endDate = date( "Y-m-j", $rawEndDate );
echo "End Date: ".$endDate."<br />";
/*
$theDate = $date1;
$dateList = array();
while ( $sqlCurrentDate != $endDate )
{
$currentDate = mktime(0, 0, 0, $month1, $theDate++ ,$year1);
$dow = date('N', $currentDate);
if ( $dow < 6 )
{
$thisDay = date( "Y-M-j", $currentDate );
echo $thisDay."<br />";
$dateList[] = $thisDay;
}
}
*/
return $dateList;
}
generateList_weekdays ( 3, 12, 2008, 5, 31, 2008 )