note 69100 added to function.date

From: Date: Wed, 23 Aug 2006 02:32:05 +0000
Subject: note 69100 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-116191@lists.php.net to get a copy of this message
mwwaygoo AT hotmail DOT com 09-Aug-2006 05:11 Posted a nice script to calculate the number of weeks in a month using the ISO 8601 standard. But I was a little bit confused why to use the strtotime function. I tweaked it a little bit, using mtime to identify the first and last day of the month and making it all possible in 4 lines. <?php for ($j = 1; $j <= 10; $j++) { $year = date("Y")+ $j -5; echo("<br>".$year."<br>"); for ($i = 1; $i <= 12; $i++) { $month = $i; $first_week_no = date("W", mktime(1, 1, 1, $month, 1, $year)); $last_week_no = date("W", mktime(1, 1, 1, $month, date('t',mktime(0,0,0,$month,1,$year)), $year)); if($last_week_no < $first_week_no) { $weeks_of_month = 53 - $first_week_no + $last_week_no; } else { $weeks_of_month = $last_week_no - $first_week_no + 1;} echo(" Month:". $month); echo(" First Week".$first_week_no); echo(" Last week". $last_week_no); echo(" Total".$weeks_of_month ."<br>"); } } ?> ---- Server IP: 83.137.20.120 Probable Submitter: 145.94.20.118 ---- X-Spam-Status: No, hits=3.3 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER, HTML_MESSAGE autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit -- https://master.php.net/note/edit/69100 Del: integrated -- https://master.php.net/note/delete/69100/integrated Del: useless -- https://master.php.net/note/delete/69100/useless Del: bad code -- https://master.php.net/note/delete/69100/bad+code Del: spam -- https://master.php.net/note/delete/69100/spam Del: non-english -- https://master.php.net/note/delete/69100/non-english Del: in docs -- https://master.php.net/note/delete/69100/in+docs Del: other reasons-- https://master.php.net/note/delete/69100 Reject -- https://master.php.net/note/reject/69100 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#116191) next »