function
getWeekDate(
$timestamp
) {
$year
=
date
(
'Y'
,
$timestamp
);
$weeknum
=
date
(
'W'
,
$timestamp
);
$day
=
date
(
'z'
,
$timestamp
);
$weekday
=
date
(
'N'
,
$timestamp
);
$firstDayOfWeek
=
date
(
'w'
,
mktime
(0,0,0,1,1,
$year
));
if
(
$weeknum
== 1) {
$startdate
=
date
(
'Y-m-d'
,
mktime
(0,0,0,1,1,
$year
));
$enddate
=
date
(
'Y-m-d'
,
mktime
(0,0,0,1,7-
$firstDayOfWeek
+1,
$year
));
if
(
$day
> 7) {
$startdate
=
date
(
'Y-m-d'
,
mktime
(0,0,0,1,
$day
+1-
$weekday
+1,
$year
));
$enddate
=
date
(
'Y-m-d'
,
mktime
(0,0,0,12,31,
$year
));
}
}
elseif
(
$weeknum
== 53) {
$startdate
=
date
(
'Y-m-d'
,
mktime
(0,0,0,1,
$day
+1-
$weekday
+1,
$year
));
$enddate
=
date
(
'Y-m-d'
,
mktime
(0,0,0,12,31,
$year
));
}
else
{
$startdate
=
date
(
'Y-m-d'
,
mktime
(0,0,0,1,
$day
+1-
$weekday
+1,
$year
));
$enddate
=
date
(
'Y-m-d'
,
mktime
(0,0,0,1,
$day
+7-
$weekday
+1,
$year
));
}
return
array
(
$startdate
,
$enddate
);
}