Jump to content

Timestamps?


3raser

Recommended Posts

PLEASE NOTE: I did check the PHP manual, although it was a bit too confusing for beginners with timestamps.

 

I'm creating a simple bank interest system for my PHP game. Say I have a 2% interest in my bank, and I want to run it every 20 minutes. How would I do this? Please provide an example as I'm a bit...too lost. :/

Link to comment
https://forums.phpfreaks.com/topic/230574-timestamps/
Share on other sites

create a db table, called bank

 

 

id | user_id | total | last_update

 

make last_update a datetime field, total an integer, user_id integer, and id integer..

 

set up a cron job to run every minute

 

inside the cron job set it up like:

mysql_query("UPDATE bank SET last_update = NOW(), total = total + (total * 0.02) WHERE last_update <= DATE_SUB(NOW(), INTERVAL 20 MINUTE)");

 

Link to comment
https://forums.phpfreaks.com/topic/230574-timestamps/#findComment-1187254
Share on other sites

create a db table, called bank

 

 

id | user_id | total | last_update

 

make last_update a datetime field, total an integer, user_id integer, and id integer..

 

set up a cron job to run every minute

 

inside the cron job set it up like:

mysql_query("UPDATE bank SET last_update = NOW(), total = total + (total * 0.02) WHERE last_update <= DATE_SUB(NOW(), INTERVAL 20 MINUTE)");

 

Thank you! Much appreciated....will take a while to remember something like that. >.<

Link to comment
https://forums.phpfreaks.com/topic/230574-timestamps/#findComment-1187260
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.