RIRedinPA Posted January 11, 2011 Share Posted January 11, 2011 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; } Quote Link to comment Share on other sites More sharing options...
RIRedinPA Posted January 11, 2011 Author Share Posted January 11, 2011 $weekarray = array($thisdate); should be $weekarray = array($monday); Still returning 1/30/2011 for a 1/5/2011 date... Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted January 11, 2011 Share Posted January 11, 2011 I posted a tested function that returns the Monday of the week for a given date in your other thread on this topic. Quote Link to comment Share on other sites More sharing options...
RIRedinPA Posted January 11, 2011 Author Share Posted January 11, 2011 I posted a tested function that returns the Monday of the week for a given date in your other thread on this topic. Oh, thanks, I'll grab that... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.