Ninjakreborn Posted May 1, 2007 Share Posted May 1, 2007 if ($currentdate_s >= $row['nextbillingdate']) { } Is that correct in identifying whether or not the current date, is after the nextbillingdate. Both are timestamps, one is a timestamp of the current date. The other one is a timestamp of the upcoming billing date (the date they need to be billed). So basically if the current date is before the time period where the billing need's to occur it doesn't need to do anything. If it's the same day, or after then it need's to do the calculations inside the if statement. Is the above code pretty much what I need (based on what I described) to figure this out. Quote Link to comment https://forums.phpfreaks.com/topic/49506-todaysdate-deadlinedate/ Share on other sites More sharing options...
clown[NOR] Posted May 1, 2007 Share Posted May 1, 2007 i think I would just go with the if (today == billdate) { do calc } Quote Link to comment https://forums.phpfreaks.com/topic/49506-todaysdate-deadlinedate/#findComment-242637 Share on other sites More sharing options...
obsidian Posted May 1, 2007 Share Posted May 1, 2007 if ($currentdate_s >= $row['nextbillingdate']) { } Is that correct in identifying whether or not the current date, is after the nextbillingdate. Both are timestamps, one is a timestamp of the current date. The other one is a timestamp of the upcoming billing date (the date they need to be billed). So basically if the current date is before the time period where the billing need's to occur it doesn't need to do anything. If it's the same day, or after then it need's to do the calculations inside the if statement. Is the above code pretty much what I need (based on what I described) to figure this out. Yes, however the logic seems to be slightly amiss. With that as it is, every time you run the script after my billing date, you're going to charge me... I don't like that Quote Link to comment https://forums.phpfreaks.com/topic/49506-todaysdate-deadlinedate/#findComment-242644 Share on other sites More sharing options...
clown[NOR] Posted May 1, 2007 Share Posted May 1, 2007 hehe Quote Link to comment https://forums.phpfreaks.com/topic/49506-todaysdate-deadlinedate/#findComment-242656 Share on other sites More sharing options...
Ninjakreborn Posted May 1, 2007 Author Share Posted May 1, 2007 Yes, but I update the last billed date with today, and the next billing date with one month from today. So it gets updated each time, keeping it from happen, I didn't post all the code because I was just wondering about that one thing. Thanks for the feedback. Quote Link to comment https://forums.phpfreaks.com/topic/49506-todaysdate-deadlinedate/#findComment-242721 Share on other sites More sharing options...
obsidian Posted May 1, 2007 Share Posted May 1, 2007 Yes, but I update the last billed date with today, and the next billing date with one month from today. So it gets updated each time, keeping it from happen, I didn't post all the code because I was just wondering about that one thing. Thanks for the feedback. One other point to make: when working with timestamps, it is accurate down to the second, so when you're comparing two timestamps, make sure that your timestamp is created with accuracy to the second, or else you'll never come up with a perfect match. Quote Link to comment https://forums.phpfreaks.com/topic/49506-todaysdate-deadlinedate/#findComment-242729 Share on other sites More sharing options...
clown[NOR] Posted May 1, 2007 Share Posted May 1, 2007 i would anyway go with == if today is the same date as billingdate then do calculations... Quote Link to comment https://forums.phpfreaks.com/topic/49506-todaysdate-deadlinedate/#findComment-242734 Share on other sites More sharing options...
Ninjakreborn Posted May 1, 2007 Author Share Posted May 1, 2007 Yes, thank you for reminding me. I am having a hard time "testing" this so I am trying to figure out a good way to debug it, I fed it a future date, to force it to do the calculations, now I can't seem to get them reset. I am going to reset the fields and test it, thanks for all the feedback. Yes, if it's a date late it won't do calculations, what if they forget to do it one day Quote Link to comment https://forums.phpfreaks.com/topic/49506-todaysdate-deadlinedate/#findComment-242737 Share on other sites More sharing options...
roopurt18 Posted May 1, 2007 Share Posted May 1, 2007 Using the == approach you can potentially not process an order. Using the >= approach you can potentially process an order more than once. Out of the two, the first is more catastrophic; either the end-user never gets their service or your client never gets their money. I'd use this approach: <?php if($today >= $billing && !$processed){ } ?> Quote Link to comment https://forums.phpfreaks.com/topic/49506-todaysdate-deadlinedate/#findComment-242769 Share on other sites More sharing options...
Ninjakreborn Posted May 1, 2007 Author Share Posted May 1, 2007 It's hard to explain, it's more of. See when I do the calculations I am updating next billing date with next month, and last billed date with THIS month. So then it's always fresh, doesn't that cover that issue entirely. Since I am using the current month to check if it's either the nextbillingdate or after, once it does process, then the next billing date is changed to next month, so if the script tries to run again, it should be able to tell that. I am going to also leave this post open, because this is only the beginning, I have a much harder (REALLY HARD) calculation part of it I have to do tomorrow, so I will probably be posting here some tomorrow when I start getting into the hairy parts of the programming. Quote Link to comment https://forums.phpfreaks.com/topic/49506-todaysdate-deadlinedate/#findComment-242865 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.