note 85745 added to function.date
| From: | domi at lab-9 dot com | Date: | Tue, 16 Sep 2008 07:14:10 +0000 |
| Subject: | note 85745 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-144436@lists.php.net to get a copy of this message | ||
<?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));
}
?>
----
Server IP: 217.160.72.57
Probable Submitter: 81.223.54.114
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- https://master.php.net/note/edit/85745
Del: integrated -- https://master.php.net/note/delete/85745/integrated
Del: useless -- https://master.php.net/note/delete/85745/useless
Del: bad code -- https://master.php.net/note/delete/85745/bad+code
Del: spam -- https://master.php.net/note/delete/85745/spam
Del: non-english -- https://master.php.net/note/delete/85745/non-english
Del: in docs -- https://master.php.net/note/delete/85745/in+docs
Del: other reasons-- https://master.php.net/note/delete/85745
Reject -- https://master.php.net/note/reject/85745
Search -- https://master.php.net/manage/user-notes.php