The ISO 8601 has the Week Date. I wrote this function. I hope that it can help someone.
If second parameter is not empty it assumes that $a is the year, $b the month and $c the day, and return basic ISO week date: YYYYWwwD (default) or extended: YYYY-Www-D (if $x is true);
If just first parameter is not empty assumes it is a ISO week date (basic or extended), and return the Unix timestamp.
function ISOwd($a,$b='',$c='',$x=false) {
if (!$b) {
if (!preg_match_all('/([0-9]{4})-*W*([0-9]{2})-*([0-9]{1})/', $a, $m, PREG_SET_ORDER))
return null;
/* Now year is $m[0][1], week is $m[0][2] and day is $m[0][3] */
$fd = mktime(0,0,0,1,1,$m[0][1]); // first day of the first week of the year
$n = date('N', $fd);
/* if ($n==7) $fd=2; if ($n==6) $fd=3; if ($n==5) $fd=4;
if ($n==4) $fd=29; if ($n==3) $fd=30; if ($n==2) $fd=31; if ($n==1) $fd=1; */
if ($n>4) $fd = mktime(0,0,0,1,9-$n,$m[0][1]);
elseif ($n>1) $fd = mktime(0,0,0,12,33-$n,$m[0][1]-1);
return strtotime(date('d-m-Y',$fd).' + '.($m[0][2]-1).' week'.' + '.($m[0][3]-1).' days');
}
$f = ($x) ? 'o-\WW-N' : 'o\WWN'; // basic / extended format
return date($f, mktime(0,0,0,$b,$c,$a));
}
// Example:
echo $test = ISOwd(date('y'),date('m'),date('d'));
echo '<br>';
echo date('y-m-d',ISOwd($test));
echo '<br>';
echo $test = ISOwd(date('y'),date('m'),date('d'),true);
echo '<br>';
echo date('y-m-d',ISOwd($test));