I'm trying to make a hit counter where I want to collect total hits for 24 hours. This 24 hours should be a fixed value regardless to the end user's time zone. Within 24 hours the database should be updated with +1 hit counts and once the 24 hour time scale achieved the timer should be reset.
Here is what I'm trying:
$timer = TIME_NOW - 60*60*24;
if ($timer < TIME_NOW)
$db->query("UPDATE settings SET value=value+1 WHERE name='hits_today'");
}
else
{
$db->query("UPDATE settings SET value=0 WHERE name='hits_today'");
}
Here TIME_NOW is a constant defined as time()
I've searched alot this site but I didn't find any answer to this question, please help, how can I go about this?
Thanks!