Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jun 2010
    Thanked 0 Times in 0 Posts

    Determining if server time was midnight?

    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?

  2. #2
    New Coder
    Join Date
    Jan 2006
    Thanked 3 Times in 3 Posts
    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
    PHP Code:
    $mode $_GET['mode']; 
    at the top of your page and then have:
    PHP Code:
    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".

  3. #3
    New Coder
    Join Date
    Jun 2010
    The Netherlands
    Thanked 6 Times in 6 Posts
    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.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts