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

Started on the old forum in December 2009 · view the original in the archive · old links redirect here

4 replies · 472 views · started 16 years ago · 1 min read

2 participants
youngbobby Developer · 55 posts #1

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 🙂

Naijatop.net = Mobile Traffic Booster 👑

📖 YoungBobby.com = Bobby's BLoG 😁

You're Welcome !!

wap2k Developer · 168 posts #2

Why not just set a counter that counts each visitor as they visit.

UPDATE database_name SET counter=counter+1

Then at 12.00 pm

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?

wap2k Developer · 168 posts #3

youngbobby wrote: 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.

$secondsleft = time() - mktime(0, 0, 0, date("m") , date("d")+1, date("Y"));

Might have parse error i havnt tested for coding errors

youngbobby Developer · 55 posts #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

Naijatop.net = Mobile Traffic Booster 👑

📖 YoungBobby.com = Bobby's BLoG 😁

You're Welcome !!

Guest #5

Use a Cron Job at midnight.

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close