How to query database to delete data at time > 00:00 hours

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to query database to delete data at time > 00:00 hours

    Hi guys, i've had problems. What i have in mind achieving is to get the total number of hits i get per day. If there's any other better than the method i want 2 use, i'll love it. Here is what i'm doing: when user visits, i calculate how many seconds from now till 00:00 hours, then add it to current time. Then i query database to delete all data where current time > user's_visit_time.
    NB: user's_visit_time = time() + seconds to 00:00 hours. My problem is how to get how many seconds to 00:00 hours. Can someone help me. Thanks

    #2
    Why not just set a counter that counts each visitor as they visit.
    Code:
    UPDATE database_name SET counter=counter+1
    Then at 12.00 pm
    Code:
    UPDATE database_name SET counter='0'
    Then if needed store previous counter it beore
    you clear to keep track of how many from the day,week,year before?

    Comment


      #3
      Originally posted by youngbobby View Post
      Hi guys, i've had problems. What i have in mind achieving is to get the total number of hits i get per day. If there's any other better than the method i want 2 use, i'll love it. Here is what i'm doing: when user visits, i calculate how many seconds from now till 00:00 hours, then add it to current time. Then i query database to delete all data where current time > user's_visit_time.
      NB: user's_visit_time = time() + seconds to 00:00 hours. My problem is how to get how many seconds to 00:00 hours. Can someone help me. Thanks
      To do this i would take the current time using the PHP time() then take away like so.

      Code:
      $secondsleft = time() - mktime(0, 0, 0, date("m") , date("d")+1, date("Y"));
      Might have parse error i havnt tested for coding errors

      Comment


        #4
        I'm quite confused. Are you subtracting how many seconds to 00:00 from current time? It's a toplist that i'm doing and it's necessary i show user how many hits he had per day

        Comment


          #5
          Use a Cron Job at midnight.

          Comment

          Working...
          X