youanden
youanden

Reputation: 386

What is/are a/some way(s) to implement a month counter for subscriptions?

I want to charge users for a service (not recurring, they are free to renew on their own).

If a user subscribes on the 1st-28th, I can simply set the expiration date in the database one month ahead. (users will not be allowed to subscribe if they are already subscribed [to avoid counting from a expiration date])

What would be a good practice if a user subscribes from the 29th-31st (varies)?

Should I just add x (1-3) days so that their subscription would expire on the 1st of the second month in advance? I'm trying to avoid a solution where I have a set of rules to apply before determining if a user's subscription has 'expired'.

I've had trouble finding other people's implementations of such things. Thanks.

I am using PHP, but I don't mind implementing a DB query that is responsible for the expiration_date requirement.

Upvotes: 0

Views: 83

Answers (1)

Digital Chris
Digital Chris

Reputation: 6202

Why worry about month starts/ends etc? Also why give people less for their money just because it's February? I suggest making it a "30 day subscription" which is easy to implement:

UPDATE subscription SET expiration=ADDDATE(Now(), INTERVAL 30 DAY)

Upvotes: 1

Related Questions