Jump to content

Calculating if it's a new week


Kemik

Recommended Posts

Hello,

 

I'm coding a budget application. Basically, the section of code I'm working on will check if today is the start of a new week and if so it will add the weeks budget to the current balance.

 

If today is > next week date
fetch budgeted amounts per week from each category and current balance
update category balance with current balance + budgeted amount
update next week date for next coming sunday

 

This piece of code will run every time the user visits the homepage. (Would this be easier to just use cron jobs?)

I'm stuck on what happens if the user doesn't visit the site for two weeks. It will only add one weeks budget to the balance.

 

Also, how would I calculate the date for the next coming sunday? I cannot use date + 7 as the user could visit on a tuesday, wednesday, etc.

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/91390-calculating-if-its-a-new-week/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.