Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

get date to current week last or first day dates


function getWeekDates($date)
{
    $week =  date('W', strtotime($date));
    $year =  date('Y', strtotime($date));
    $from = date("Y-m-d", strtotime("{$year}-W{$week}-1")); //Returns the date of monday in week
    $to = date("Y-m-d", strtotime("{$year}-W{$week}-7"));   //Returns the date of sunday in week
    
    $returnArray = array();
    $returnArray['start_date'] = $from;
    $returnArray['end_date'] = $to;
    return $returnArray;
    //echo "Start Date-->".$from."End Date -->".$to;//Output : Start Date-->2012-09-03 End Date-->2012-09-09
}
 
PREVIOUS NEXT
Tagged: #date #current #week #day #dates
ADD COMMENT
Topic
Name
1+9 =