Jump to content

$todaysdate >= $deadlinedate


Ninjakreborn

Recommended Posts

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.

Link to comment
Share on other sites

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 ;)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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){
  }
?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.