note 67032 added to function.date

From: Date: Fri, 02 Jun 2006 11:22:25 +0000
Subject: note 67032 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-112944@lists.php.net to get a copy of this message
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; } ?> ---- Server IP: 217.174.203.10 Probable Submitter: 217.109.186.46 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit -- http://master.php.net/note/edit/67032 Del: integrated -- http://master.php.net/note/delete/67032/integrated Del: useless -- http://master.php.net/note/delete/67032/useless Del: bad code -- http://master.php.net/note/delete/67032/bad+code Del: spam -- http://master.php.net/note/delete/67032/spam Del: non-english -- http://master.php.net/note/delete/67032/non-english Del: in docs -- http://master.php.net/note/delete/67032/in+docs Del: other reasons-- http://master.php.net/note/delete/67032 Reject -- http://master.php.net/note/reject/67032 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#112944) next »