Jump to content

PHP date() issues...


RIRedinPA

Recommended Posts

I'm trying to write a function that'll give me the days of the week of any submitted date. This keep returning 1/30/2011 even though I am submitting 1/05/2011 (the Monday should be 1/03/2011)...I know it's incomplete I'm just trying to get the Monday right now

 


function getWeekDays($date) { 
    	
//convert string to date
$thisdate = date($date);


$dow = idate('w', mktime(0,0,0,$thisdate));
    	
if ($dow == 1) { 
	$monday = date('m/d/Y', mktime(0,0,0, date('m'), date('d', $thisdate), date('Y')));
} else if ($dow == 2) { 
	$monday = date('m/d/Y', mktime(0,0,0, date('m'), date('d', $thisdate) - 1, date('Y')));
} else if ($dow == 3) { 
	$monday = date('m/d/Y', mktime(0,0,0, date('m'), date('d', $thisdate) - 2, date('Y')));
} else if ($dow == 4) { 
	$monday = date('m/d/Y', mktime(0,0,0, date('m'), date('d', $thisdate) - 3, date('Y')));
} else if ($dow == 5) { 
	$monday = date('m/d/Y', mktime(0,0,0, date('m'), date('d', $thisdate) - 4, date('Y')));
}

$weekarray = array($thisdate);

    return $weekarray;
}

Link to comment
https://forums.phpfreaks.com/topic/224106-php-date-issues/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.