note 9290 added to date

From: Date: Thu, 26 Oct 2000 11:24:23 +0000
Subject: note 9290 added to date
Groups: php.notes 
Request: Send a blank email to php-notes+get-7014@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") . "."; http://www.php.net/manual/function.date.php

« previous php.notes (#7014) next »