Re: Automatic Billing
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

Re: Automatic Billing

From: Kimmo Laine <eternal.erectionN0.5P@Mgmail.com>
Date: Sun Jul 31 2005 - 19:27:26 CEST

"Dream Web Host" <robjones2005@blueyonder.co.uk> kirjoitti
viestissä:1122829002.747655.249740@g49g2000cwa.googlegroups.com...
> Hi,
>
> I am creating a Web hosting billing program and require a script which
> will output the date next month, obviously this can be difficult due to
> different numbers of days in different months. It needs to be able to
> differ between monthly payments, quarterly and also yearly.
>
> Any tips?

Don't know exactly what you are looking for, but one thing is sure, if you
can't handle it with date(), mktime() and strtime(), your thinking too
complicated.

Different number of days in month is no problem, you can get the number of
days in february for example with
$february_first = mktime(0,0,0, 2,1,2005); // Creating a timestamp for
february 1st 2005.
date('t', $february_first); // the t parameter gives the number of days.

With mktime(0,0,0, $month,1,2005) you can create timestamps for billingdates
for each first of the month by altering the value of $month.

With strtotime() you can advance by days, months. I'm not sure if years, but
12 months should do it. Okay, you have billing date, and you need the next,
that's easy. Is it 1 month, 3 months or 12 months?

$next_billing_date = strtotime("+$months months", $current_billing_date);
//Where $months is either 1, 3 (as in a quarter) or 12 for entire year.

You should get started with those. Feel free to explain your problem further
to get a proper answer. :)

-- 
SETI @ Home - Donate your cpu's idle time to science.
Further reading at <http://setiweb.ssl.berkeley.edu/>
Soulman <eternal.erectionN0@5P4Mgmail.com> 
Received on Tue Oct 18 02:06:35 2005