note 9290 deleted from date by ronabop

From: Date: Sat, 10 Mar 2001 23:03:32 +0000
Subject: note 9290 deleted from date by ronabop
Groups: php.notes 
Request: Send a blank email to php-notes+get-12220@lists.php.net to get a copy of this message
Below is a function which returns week of year. I think, other functions published here in these user notes are incorrect. Try them and try this one and compare result with callendar. If you have any questions or you are in a doubt, please send me an e-mail. function weekofyear() { $today = time(); // Today... (DD.MM.YYYY) $firstjan = mktime(0, 0, 0, 1, 1, date("Y")); // 1. 1. YYYY $week = ceil((($today - $firstjan) / (3600 * 24) - 1 + date("w", $firstjan)) / 7); // Week of Year (YYYY) return $week; } echo "Now is " . weekofyear() . ". week of year " . date("Y") . ".";

« previous php.notes (#12220) next »