Hi,
Let's say that guy register's to my site for 5$ for 30 days. So how do I make code that automaticly after 30 days delete's his account?
Thanks for answers and sorry for poor english Respectfully, Tom
Hi,
Let's say that guy register's to my site for 5$ for 30 days. So how do I make code that automaticly after 30 days delete's his account?
Thanks for answers and sorry for poor english Respectfully, Tom
Use the date handling functions of your preferred programming language. Do not attempt to implement it yourself. It's harder than you think.
Most likely you would run a cron job every day or so and check and see if an account's last payment was 30 days ago, and then delete the user. However, manipulating the date is difficult to explain unless we know what language you are using. Since you specified DateTime I'm going to assume that you mean the .NET DateTime object and then you can just do DateTime.addMonths(-1); or DateTime.addDays(-30) respectively.
If you can, convert the registration date and the current time to UNIX timestamps. Then subtract their registration time from the current time and check if the result is greater than the number of seconds in 30 days. (60 seconds * 60 minutes * 24 hours * 30 days = 2592000 seconds.)
If you just have to count 30 days you can count them as 30 * 24 * 60 * 60 = 2592000 seconds and simply subtract the unix timestamps.
Anything more complex than this is a PITA to implement yourself and yuo should follow recursive's advice.
wxWidgets has good date handling functions, as well as many others.
I'd suggest simply noting the account's expiration date in its record, rather than having some sort of scheduled process to delete expired accounts.
For a .Net example: when you receive the $5 payment, set the account's expiration date to DateTime.Now.AddDays(30), and reject login on an account where expirationDate < DateTime.Now.
In Java, you'd need to pour the Date into a Calendar in order to add days, then pour it back into a Date when you're done.
However, what facilities are available to handle dates are determined by your environment.
WOW! I didn't expected so many answers so fast. I found what I was searching. Thanks again.
in sql, I'd like to list all funds whose anniversary is due this year in 2 months time. what is the syntax?