Getting week dates of the current month

by mariganesh 2013-02-12 12:32:45

Getting week dates of the current month


$year=date("Y");
$month=date('m');
$datee=strtotime("$curr_yea-$curr_mon");
$cur_end=date("Y-m-d",strtotime("+1 month -1 second",$datee));//date("Y-m-t", strtotime("-1 now") ) ;
$end = new DateTime("$cur_end");
$endTimestamp = $end->getTimestamp();
$now = new DateTime("$curr_yea-$curr_mon-01");
$now->setTime(0,0);
if (($now->format("l") == "Saturday") || ($now->format("l") == "Sunday"))
$d = $now;
else
$d = $now;

$oneday = new DateInterval("P1D");
$sixdays = new DateInterval("P6D");
$res = array();

while ($d->getTimestamp() <= $endTimestamp) {
$res[] = $d->format("Y-m-d");
$d = $d->add($oneday);
if ($d->getTimestamp() <= $endTimestamp) {
$res[] = $d->format("Y-m-d");
}
$d = $d->add($sixdays);

}
print_r($res);
968
like
0
dislike
0
mail
flag

You must LOGIN to add comments