note 79589 deleted from function.date by betz
| From: | betz@php.net | Date: | Tue, 04 Dec 2007 23:35:19 +0000 |
| Subject: | note 79589 deleted from function.date by betz | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-132826@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymous
Reason: useless
----
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.