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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.