Nismo
Member
Registered: 12th Sep 02
User status: Offline
|
I am in the process of creating an Invoice Manager / Diary.
I need to be able to add an entry to a table and choose the reoccurring billing interval from a defined date, i.e 1 week, 1 month, quarterly, 6 monthly or annually.
this just populates all the dates, then i can add them to the db.
Then the user goes to a list each day and it lists the invoices to be sent out on that day.
Anyone fancy creating this function, simply name your price
|
Paul_J
Member
Registered: 6th Jun 02
Location: London
User status: Offline
|
Does it have to be php?
Sounds pretty simple.
|
Ian
Site Administrator
Registered: 28th Aug 99
Location: Liverpool
User status: Offline
|
So you have a current date, you want to add a time period and give you another date?
Loads of inbuilt functions to do that.
|
Dom
Member
Registered: 13th Sep 03
User status: Offline
|
Messy and rough as hell, no doubt Ian & co could better it (especially for efficiency) -
code:
function GenDateList($initDate, $interval) {
$calculate_years = 5; // Number of years to generate
$return_array = array();
$loopDate = date("d-m-Y", $initDate);
$stopYear = intVal(Date("Y", $initDate)) + $calculate_years;
$loopYear = 0;
$arrayPointer = 0;
while ($loopYear <= $stopYear) {
$return_array[$arrayPointer] = $loopDate;
$loopDate = date("d-m-Y", strtotime($loopDate." ".$interval));
$loopYear = intVal(date("Y", strtotime($loopDate)));
$arrayPointer++;
}
return $return_array;
}
$rtrn_arr = GenDateList(strtotime("16-03-2012 00:00:00"), "+1 Months");
print_r($rtrn_arr);
[Edited on 16-03-2012 by Dom]
|