On Mon, 25 Aug 2003 16:41:36 +0200, Jesper Hansen <sebulba_@mailme.dk>
wrote:
>>Nej ovenstående burde skrive 34, men strftime("%V", $unixtimestamp); burde
>>skrive 35, da den overholder ISO 8601:1988.
>
>Jo - mange tak
Det skal lige siges at '%V' ikke virker på windows. Her er en
workarround, der skulle virke på de fleste systemer:
<?php
echo ISOWeek(2003, 8, 25);
function ISOWeek($y, $m, $d)
{
$week=strftime("%W", mktime(0, 0, 0, $m, $d, $y));
$dow0101=getdate(mktime(0, 0, 0, 1, 1, $y));
$next0101=getdate(mktime(0, 0, 0, 1, 1, $y+1));
if ($dow0101["wday"]>1 &&
$dow0101["wday"]<5)
$week++;
if ($next0101["wday"]>1 &&
$next0101["wday"]<5 &&
$week==53)
$week=1;
if ($week==0)
$week = ISOWeek($y-1,12,31);
return(substr("00" . $week, -2));
}
?>
--
Med Venlig Hilsen
c",) Martin S