After reading countless topics and javascript stuff about finding the CORRECT weeknumber (since most have a week 0 and/or a week 53 as a result), I found this piece of code on this site:
function is_leap_year($year)
{
if ((($year % 4) == 0 and ($year % 100)!=0) or ($year % 400) == 0)
return 1;
else
return 0;
}
function iso_week_days($yday, $wday) {
return $yday - (($yday - $wday + 382) % 7) + 3;
}
function get_week_number($timestamp) {
$d = getdate($timestamp);
$days = iso_week_days($d["yday"], $d["wday"]);
if ($days < 0) {
$d[ "yday"] += 365 + is_leap_year(--$d["year"]);
$days = iso_week_days($d["yday"], $d["wday"]);
}
else {
$d["yday"] -= 365 + is_leap_year($d["year"]);
$d2 = iso_week_days($d["yday"], $d["wday"]);
if (0 <= $d2)
$days = $d2;
}
return (int)($days / 7) + 1;
}
the only problem is, I don't know how to make it work... if I just execute the functions, I get an error saying something about the vars in the functions.
Is there a way to transform these functions in a normal follow up, so you could just execute the stuff, and get the result on the in as a variable?
like this
code
code
code
code
code
coderesult
Thanks,
Menno
(I sure hope this code works though 🙂