[thelist] Get time
Jackson Yee
jyee at vt.edu
Mon Sep 30 22:29:01 CDT 2002
"wade" <wade at bayou.com> wrote in message news:3D98C75B.96636AD2 at bayou.com...
> Could anyone help me to figure out how to write a piece of code that says
> if the time now time( ) is greater than 1 hour of the time( )then do
> something.
> I have a script that gets the time as of now and I also have the time of
> (lets say then) stored in a database.
> how would I write the code to say if the old time is greater than 1 hour
do
> something?
>
> $subtracted_time = $time_now - $stored_database_time;
> if ($subtracted_time > mktime(1,0,0,0,0,0))
I'm guessing that you're using PHP, since I'm not familiar with dollar sign
prepended variables and mktime() in any other language. ;-)
The code that you have should work fine. Alternatively, you can simply say
if ($time_now > ($stored_database_time + mktime(1, 0, 0, 0, 0, 0))
{
}
and it would be the same thing.
I use the same code myself to logout users who have been idle for too long,
so let me know how things go.
--
Regards,
Jackson Yee
jyee at vt.edu
http://www.jacksonyee.com/
More information about the thelist
mailing list