note 57128 deleted from function.date by derick

From: Date: Sun, 15 Jan 2006 12:40:41 +0000
Subject: note 57128 deleted from function.date by derick
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-101822@lists.php.net to get a copy of this message
Note Submitter: liam at sunwise dot co dot uk ---- 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 :-)

« previous php.notes (#101822) next »