note 71722 added to function.getdate

From: Date: Wed, 13 Dec 2006 12:38:52 +0000
Subject: note 71722 added to function.getdate
Groups: php.notes 
Request: Send a blank email to php-notes+get-120571@lists.php.net to get a copy of this message
I thought best to show a posseble way to go about bypassing the end month issue where the first day in a new month will have the monday of the week that it falls in - in the old month. Use the numbering of days as the constant and work you way from there. Example: <?php //----------------------------- $now = time(); $num = date("w"); if ($num == 0) { $sub = 6; } else { $sub = ($num-1); } $WeekMon = mktime(0, 0, 0, date("m", $now) , date("d", $now)-$sub, date("Y", $now)); //monday week begin calculation $todayh = getdate($WeekMon); //monday week begin reconvert $d = $todayh[mday]; $m = $todayh[mon]; $y = $todayh[year]; echo "$d-$m-$y"; //getdate converted day ?> Allot less code makes everyone happy.. ---- Server IP: 212.124.37.9 Probable Submitter: 192.109.190.88 (proxied: 172.16.86.76) ---- Manual Page -- http://www.php.net/manual/en/function.getdate.php Edit -- https://master.php.net/note/edit/71722 Del: integrated -- https://master.php.net/note/delete/71722/integrated Del: useless -- https://master.php.net/note/delete/71722/useless Del: bad code -- https://master.php.net/note/delete/71722/bad+code Del: spam -- https://master.php.net/note/delete/71722/spam Del: non-english -- https://master.php.net/note/delete/71722/non-english Del: in docs -- https://master.php.net/note/delete/71722/in+docs Del: other reasons-- https://master.php.net/note/delete/71722 Reject -- https://master.php.net/note/reject/71722 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#120571) next »