This is a discussion on "if time is now is new hour then.." within the PHP Forum section. This forum, and the thread "if time is now is new hour then.. are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
if time is now is new hour then..
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
Hi,
Im trying to think of a way to write a piece of code that basiaclly does this. If the time now is a new hour then... If the time now is a new day then... if the time is a new week then... if the time now is a new month then... once I have that I can create mysql tables at the right time to store data. Thanks in advance! |
|
|
|
#2
|
|||
|
|||
|
Re: if time is now is new hour then..
That description is a bit cryptic. ^^
Do you want to check if it is a new hour since ANYBODY opened up the php page last time? Or just a specific IP? Or a user? Anybody: Write information to text file, check text file with script. IP / User: Use mysql table and write information for every ip/user in there. Check with script. |
|
#3
|
|||
|
|||
|
Re: if time is now is new hour then..
Sorry. I seem to be having one of those days where whatever I post I just confuse everybody.
No I want to get the php to check the server time and if the time is 15:59 then it is not a new hour since it last check at 15xx (stored in mysql table), but if the time was 16:02 then it would be a new hour so therefore continue. Basically I need that to happen per hour, per day, per week, and per month. Thanks. Last edited by eon201; Nov 7th, 2007 at 14:53. |
|
#4
|
||||
|
||||
|
Re: if time is now is new hour then..
Why not just use a cron job?
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
#5
|
|||
|
|||
|
Re: if time is now is new hour then..
excuse my ignorance.... what is a cron job???
|
|
#6
|
|||
|
|||
|
Re: if time is now is new hour then..
Whats going on, my post "use a cronjob" is gone... *grml* ^^
A Cronjob can be set at your webserver. It is a little timer (or more) which do something at a specific time. You can set one "do stuff every hour" running one script, one "do stuff every 24hours" running another script. Try Google: http://www.google.com/search?hl=en&q=cronjob |
|
#7
|
|||
|
|||
|
Re: if time is now is new hour then..
oh right yer i know what you mean now. The problem is that the script will be run on the server once every fifteen minutes.
But within the script itself I need it to write to different mysql tables depending on the date/time for hours/days/weeks and months. And I really want it to all run within the one script. Thanks so far, but any more suggestions#? |
|
#8
|
||||
|
||||
|
Re: if time is now is new hour then..
Oh right, use the time() function.
http://uk2.php.net/time
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
#9
|
|||
|
|||
|
Re: if time is now is new hour then..
ok cool. But back to my original question..
How would I implement that to work out if this is a new hour,day,week or month comparitive to the last time that each corresponding mysql table was updated?? Thanks again. |
|
#10
|
|||
|
|||
|
Re: if time is now is new hour then..
The MYSQL Table has some implemented informations. One is "update time". You can check at which something was added or modified.
So get that update time form your table with
|
|
#11
|
|||
|
|||
|
Re: if time is now is new hour then..
After a lot of coming and going. I have come to the conclusion that I need the script to activate certain parts of itself at different times of the day (the whole script will re run every 20secs) eg. run part a at 15:45 and 16:00, run part b at 9:00 and :9:30.
I hope someone can help me with this as I am stumped! |
|
#12
|
|||
|
|||
|
Re: if time is now is new hour then..
If you want the script to be executed at fixed times at the day, just get the current time
Last edited by c010depunkk; Nov 9th, 2007 at 08:31. Reason: [code] became [php] |
![]() |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| 2 Hour Website | shawzy85 | Free Web Site Critique | 22 | Jul 9th, 2008 19:24 |
| 4 hour Website | shawzy85 | Free Web Site Critique | 8 | Apr 28th, 2008 22:03 |
| Every half hour script | Blake121 | PHP Forum | 5 | Aug 18th, 2007 10:29 |
| Adjusting time from server time to local time | Tim356 | Classic ASP | 10 | Jun 21st, 2004 14:57 |
| 24 hour time calculation | kinjiro | JavaScript Forum | 9 | Sep 20th, 2003 06:40 |