...

View Full Version : If the time now is a new hour then...



eon201
11-07-2007, 03:35 PM
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!

Inigoesdr
11-07-2007, 05:42 PM
http://en.wikipedia.org/wiki/Cron

psykx
11-08-2007, 12:13 AM
you could use a cookie. I'm still learning php so I can't code this with out referring to a manual. But...

create an array with hour, day, week, month ($now)

if cookie exists then read data into array $then, else create cookie with $now

then test the arrays against each other

psykx
11-08-2007, 12:22 AM
if ($now['hour'] = ($then['hour'] + foo))
{
do hour thing
}


where foo is the int of one hour or whatever time
etc...

Inigoesdr
11-08-2007, 04:08 AM
It depends on how you want the content changed. If you want something to execute for each user as the hour/whatever changes use a cookie. If you want all users to affect it then you just need to store the time in a file(preferably) or database, and compare it when the page loads. file_put_contents() (http://php.net/file_put_contents) file_get_contents() (http://php.net/file_get_contents) time() (http://php.net/time)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum