note 47207 deleted from function.mktime by tomsommer

From: Date: Sun, 07 Nov 2004 20:27:13 +0000
Subject: note 47207 deleted from function.mktime by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-80239@lists.php.net to get a copy of this message
Note Submitter: Erik Oskam ---- I was looking for a way to convert a week- and daynumber to a UNIX timestamp. I found Robert Christaanse code below but I found it a bit wordy so I rewrote it to this function: <?PHP function datefromweeknr($year, $week, $day) { $jan04 = mktime (0,0,0,01,4, $year); // jan 04 always in week 1 $firstday = date("w", $jan04); // fetch day of week of jan 04 $offset = ($week-2) * 7 - $firstday + $day; //calc number of days difference from jan 04 return strtotime('+' .$offset .' days', $jan04); } ?> Hope it helps out ;)

« previous php.notes (#80239) next »