note 41758 added to function.getdate

From: Date: Wed, 21 Apr 2004 18:58:58 +0000
Subject: note 41758 added to function.getdate
Groups: php.notes 
Request: Send a blank email to php-notes+get-68470@lists.php.net to get a copy of this message
getdate does not convert week numbers. this function relies on strftime to find a timestamp that falls on the monday of specified year and ISO week: <?php function getisomonday($year, $week) { # check input $year = min ($year, 2038); $year = max ($year, 1970); $week = min ($week, 53); $week = max ($week, 1); # make a guess $monday = mktime (1,1,1,1,7*$week,$year); # count down to week while (strftime('%V', $monday) != $week) $monday -= 60*60*24*7; # count down to monday while (strftime('%u', $monday) != 1) $monday -= 60*60*24; # got it return $monday; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.getdate.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+41758 Delete -- http://master.php.net/manage/user-notes.php?action=delete+41758&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+41758&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#68470) next »