Forum Moderators: coopster
$current_half_hour = floor(mktime()/1800);
//mktime() returns the number of seconds since 1/1/1970.
//the above would return the number of full half-hours since 1/1/1970
$previous_half_hour = // get the previous value from db or file
if ($current_half_hour > $previous_half_hour) {
$add_points = $current_half_hour - $previous_half_hour;
$sql = "UPDATE users SET points = points + $add_points";
//run the above query on the presumed user database
$previous_half_hour += $add_points; //update counter record with new value
}
Warning: make sure you preset the counter record with the value for the current half hour (or somewhat earlier if you want to make the points retroactive to some date). If it starts at zero, you'll give everyone about 600,000 points the first time around!
I hope this helps