Ello,
I am struggling with some date troubles here in PHP/MySql. I have a form that offers the recurrence of a payment yearly,quarterly,monthly,bi-weekly,or weekly and I need to be able to track when payments are made.
So for example, if something is added on Monday March 8th (that's the date it is being entered), recurring Weekly on Thursdays (the user would only see a dropdown offering days of the week -- as the recurrence is weekly), it would enter the 52 (weekly) due dates into the db (julian/whatever is easiest), and mark the first 9 of them paid (since those days are past); the rest entered but marked unpaid.
I have a table that would have each due_date entry, with a link to the payment detail, and a Boolean field paid/not paid.
So in the above example, the payments table would look something like:
id | pmnt_id | due_date | is_paid
1 | 0023 | 01/07/10 | 1
2 | 0023 | 01/14/10 | 1
3 | 0023 | 01/21/10 | 1
10 | 0023 | 03/25/10 | 0
11 | 0023 | 04/01/10 | 0
etc...
The problem is, well, everything. The calendaring system is so effed up, that there seems no real logical/straightforward way to do this. I've been racking my brain, searching goggle and php date manual all morning, and I'm just getting more confused.
Any ideas/suggestions/pointers would be greatly appreciated.
Cheers.
[snip]
$startDate = strtotime("$currentDay $currentMonthFull $currentYear");
$stTimeFormatted = strftime('%d/%m/%Y',$startDate);
$numPmnts = ($totalWeeks-$currentWeek);
for($i=0;$i<$numPmnts;$i++){
$ddates=array(
'sched_pay_id'=>$pmntID,
'due_date'=>date('m/d/y', strtotime('+'.$i.' week', $startDate)),
'is_paid'=>0,
);
$this->db->insert('sched_payments',$ddates);
}