note 57128 added to function.date
| From: | liam at sunwise dot co dot uk | Date: | Sat, 24 Sep 2005 17:43:03 +0000 |
| Subject: | note 57128 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-95714@lists.php.net to get a copy of this message | ||
If you wish to add a certain amount of days on from the present date then this should work. Just
change the $invoice_day to the amount of days you wish to add on! This also takes into account the
months and years, as you wouldn't want 42-10-05 as the next date! This will work well for
adding upto 28 days from the present.
<?php
$month = date("m");
$year = date("Y");
$day = date("d");
$last_day = date( "d", mktime(0, 0, 0, $month + 1, 0, $year) ) ;
$invoice_day = 14;
echo 'The invoice will be due in '.$invoice_day.' days.<br><br>';
$next_term = $day + $invoice_day;
if ($last_day < $next_term){
echo "The last day of the month is $last_day";
$final = $next_term - $last_day;
echo '.<br><br>';
$month = $month + 1;
if ($month == '13'){
$year = $year + 1;
$month = '01';
}
$pay_date = $final.' - '.$month.' - '.$year;
echo "This will make the invoice due date the $pay_date";
}else{
echo "The last day is $last_day. <br>";
$pay_date = $next_term.' - '.$month.' - '.$year;
echo "This will make the invoice due date the $pay_date";
}
?>
Hope it helps anyone,
Liam
:-)
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+57128
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+57128&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+57128&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+57128&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+57128&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+57128&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+57128&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+57128&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+57128&report=yes
Search -- http://master.php.net/manage/user-notes.php