Jump to content

Determining if server time was midnight?


Smudly

Recommended Posts

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?

Link to comment
Share on other sites

I don't see how that helps you.  What makes more sense is to store the current Date.  Your clientside ajax or whatever, can periodically check this at the server.  If on any poll, the startDate != the serverDate, then you do your reset.  Needless to say the date changes at midnight, but when you think about it, midnight is simply an indication that you're in a new day.

Link to comment
Share on other sites

Alright, ya I'm not sure if Cron is what I'm after. Here is a bit of code that another person helped me setup. What do you guys think? Could this work?

 

if (!isset($_SESSION["date"]) || $_SESSION["date"] != date("Ymd")) {
        $_SESSION["date"] = date("Ymd");
        $_SESSION["bonus"] = 0;
} else {
        $_SESSION["bonus"]++;
}

echo "Counter = ", $_SESSION["bonus"];

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.