note 79589 added to function.date

From: Date: Tue, 04 Dec 2007 18:43:57 +0000
Subject: note 79589 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-132807@lists.php.net to get a copy of this message
I needed to show next month info regardless of the day of the month and the number of days in the next month. As the example #3 (in my case is next month) <?php $lastmonth = mktime(0, 0, 0, date("m")-1, date("d"), date("Y")); ?> doesn't work, I came with this one. <?php $month_0 = date('m'); $month_0_numb_days = date('t'); $month_1 = date('m'+1); $month_1_timestamp = mktime(0, 0, 0, date('m')+1, date('d'), date('Y')); $month_1_numb_days = date('t', $month_1_timestamp); $diff_0_1 = ($month_0_numb_days - $month_1_numb_days); if ($todays_date_number < $month_1_numb_days) { $month_1a_timestamp = mktime(0, 0, 0, date('m')+1, date('d'), date('Y')); } else { $month_1a_timestamp = mktime(0, 0, 0, date('m')+1, date('d')-$diff_0_1, date('Y')); } $month_1 = date('m', $month_1a_timestamp); ?> Please feel free to comment and suggest. ---- Server IP: 69.147.83.197 Probable Submitter: 216.252.70.42 ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit -- https://master.php.net/note/edit/79589 Del: integrated -- https://master.php.net/note/delete/79589/integrated Del: useless -- https://master.php.net/note/delete/79589/useless Del: bad code -- https://master.php.net/note/delete/79589/bad+code Del: spam -- https://master.php.net/note/delete/79589/spam Del: non-english -- https://master.php.net/note/delete/79589/non-english Del: in docs -- https://master.php.net/note/delete/79589/in+docs Del: other reasons-- https://master.php.net/note/delete/79589 Reject -- https://master.php.net/note/reject/79589 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#132807) next »