View Full Version : Determining if server time was midnight?
06-22-2010, 04:20 AM
I've got a variable that will increment upon a user's action. Example: They click a link, and it adds 1 to the variable. The variable is then shown to the screen. I want this variable to be reset to 0 for the user, anytime the server's time has hit Midnight.
Could you provide a simple example script that does something like this so I can examine it and learn how it works please?
06-22-2010, 09:42 AM
Sounds like you would need to do a cron job or schedule your OS to automatically run a script to reset the variable. You could put
$mode = $_GET['mode']; at the top of your page and then have:
if ($mode == "resetvar") $var = 0;Then again it could always be a security issue depending on your use. The URL would be something like "file.php?mode=resetvar".
06-22-2010, 10:16 AM
Store the variable and the time/date the variable, was set to 1, and an IP in a cookie/database.
Upon the next load of the webpage from that user, check if a day has passed, and then reset the variable to 0 if it has been midnight already.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.