Nu kom jeg væk fra det .. men her er det:
Ovenstående suppleres med:
function weekstart_mon() {
/* array for switching the week to begin
from monday instead of sunday */
$week=array(6,0,1,2,3,4,5);
$p=$week[date("w",mktime(0,0,0,1,1,date("Y")))];
if($p<4)
$start=$pB+1;
else
$start=$p+($p-7);
$today=$week[date("w")];
/* no rounding is needed since we
always get full weeks */
$ugestart = mktime(0,0,0,date("m") ,date("d")-$today,date("Y"));
return $ugestart; }
og:
function weekend_mon() {
/* array for switching the week to begin
from monday instead of sunday */
$week=array(6,0,1,2,3,4,5);
$p=$week[date("w",mktime(0,0,0,1,1,date("Y")))];
if($p<4)
$start=$pB+1;
else
$start=$p+($p-7);
$today=$week[date("w")];
/* no rounding is needed since we
always get full weeks */
$ugeslut = mktime(0,0,0,date("m") ,date("d")+(6-$today),date("Y"));
return $ugeslut; }
Og der kan så skrives:
<?
echo "Vi er i uge: '".weekofyear_mon()."'<BR>\n";
echo "Ugen startede: '".date ('l dS of F Y', weekstart_mon())."' og slutter: '".date ('l dS of F Y', weekend_mon())."'<BR>\n";
?>
Formater unix-timestampet som du har lyst, naturligvis.
Kører på:
http://www.datamatikeruddannelsen.dk/spouls1/phptryouts/weekofyear.php3 og kan hentes fra:
http://www.datamatikeruddannelsen.dk/spouls1/phptryouts/weekofyear.zip