如何每30天自动更新数据库中的帐户余额

I have a customer table in my database. This table contains customer information including his/her balance.

Now I want to add his/her balance after every 30 days depends on what promo or plan he/she applied

example: he applied for a plan 1599 so after every 30 days his balance must add the price of the plan he applied.

current balance = 0 after 30 days balance = 1599

How will i do this?

You can create a cron job for the same. Check the date difference for every user and if its greater than 30 days add the balance to the respective user's account.

You can do this like

  1. Store the Date when user choose plan by using date('Y-m-d') in a variable
  2. Add 30 Days in it by using date('Y-m-d',strtotime("+7 day", $date)) and save this in database
  3. Write a query to check that date of today is equal to that stored date or not if so then add points to that account.

For point 3 you may also need cron job depends on your requirement.

If still need help feel free to comment