note 71722 deleted from function.getdate by salathe

From: Date: Mon, 21 Sep 2020 14:32:29 +0000
Subject: note 71722 deleted from function.getdate by salathe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-215193@lists.php.net to get a copy of this message
Note Submitter: andre at anlex dot co dot za ---- 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..

« previous php.notes (#215193) next »