note 67032 deleted from function.date by derick

From: Date: Sun, 11 Jun 2006 11:48:31 +0000
Subject: note 67032 deleted from function.date by derick
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-114277@lists.php.net to get a copy of this message
Note Submitter: jt dot dont_spam_me at jtis dot de ---- To Max222: Here is a oneliner that does the same... ISO 8601-compliant. <?php function WeeksOfYear($y) { return max(52,date("W",mktime(0,0,0,12,31,$y))); } ?> In addition, here's the function I use to get start and end of week (input: week and year, output: array with start and end date): <?php function get_week($w, $y) { $df = "Y-m-d"; // date format to return while (date("w",$fs = mktime(0,0,0,1,$i++,$j)) != 0); // find first sunday in the given year $r[0] = $r['start'] = date($df,$w * 604800 + $fs - 518400); // 518,400 sec = 6 days $r[1] = $r['end'] = date($df,$w * 604800 + $fs); // 604,800 sec/week = 7 days/week * 24 h/day * 3600 sec/h return $r; } ?>

« previous php.notes (#114277) next »