note 85745 deleted from function.date by derick

From: Date: Sun, 26 Oct 2008 12:58:27 +0000
Subject: note 85745 deleted from function.date by derick
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-145767@lists.php.net to get a copy of this message
Note Submitter: domi at lab-9 dot com ---- <?php # # retrieve total count of weeks in a year # # param: (int) $year the year in which you wanna get the week count; if not int (for example from date('Y') it is automatically casted # # --- NOTE: # seen a lot of stuff around but nothing as fast; # mktime() is a very performant operation and the loop # is executed max 13 times # # # see: http://www.php.net/mktime # see: http://www.php.net/intval # function total_weeks($year) { if(!is_int($year)) $year = intval($year); $i=31; while(date('w', mktime(23,59,59,12,$i,$year)) != 0) $i--; return date('W', mktime(23,59,59,12,$i,$year)); } ?>

« previous php.notes (#145767) next »