I need help with this little time function. After thirty minutes, I want an echo to occur...
[PHP]
$_SESSION['idlemin']=date(i); //This makes the session update each time the page is refreshed but was defined on log in.
$minutes=date(i); //Current
if ($_SESSION['idlemin']>=$minutes+30) {
echo "Your time is up!";
}
[/PHP]
Now, I know this doesn't work for obvious reasons...
Say you logged in at 14:49 well, it would have to equal 14:79 to work and well, time isn't calculated that high so I need something that can spill over hours..
11 1755
Taking the server time use the strtotime function, e.g.
[php]echo "30 minutes from now = " . date("H:m:s", strtotime("+30 minutes"));[/php]
Ronald :cool:
Taking the server time use the strtotime function, e.g.
[php]echo "30 minutes from now = " . date("H:m:s", strtotime("+30 minutes"));[/php]
Ronald :cool:
Tiny syntax error though...
[PHP]date("H:m:s", strtotime("+30 minutes"))[/PHP]
should be
[PHP]date("H:i:s", strtotime("+30 minutes"))[/PHP]
Sorry, my mistake. That's what you get when trying to do it without looking at the manual.
Ronald :cool:
Another quickie on time.. could you compare times?
[PHP]
$idletime=$_SESSION['idle'];
if (date("H:i:s")>=$idletime) {
echo "<META HTTP-EQUIV='refresh' content='0; url=idleout.php'>";
} elseif (date("H:i:s")<=$idletime) {
$idletime=date("H:i:s", strtotime("+30 minutes"));
}
[/PHP]
And on a different page...
[PHP]$_SESSION['idle']=date("H:i:s", strtotime("+30 minutes"))[/PHP]
Why would you format the timestamp in this case. It would be sufficient to just use the Unix timestamp and calculate and compare with that. The format makes it rather difficult.
Ronald :cool:
Do you mean that gigantic interger gotten when you use the $_SERVER['request_time'] function?
It is just the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).
But yes, that is the time format I mean. In your case the 30 minutes is just 1800 seconds.
Ronald :cool:
Actually, I've found what I wrote to work perfectly fine, suprisingly.. Just changed minutes to seconds for the test and it works.
When it works: stick with it.
Ronald :cool:
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Ken |
last post by:
Hello
Anyone know of a site with tutorial on calculating the steps in program or
in a pseudo code:
Ex: for( int =0 ; i<n ; i++) so int=0 will be executed once / i<n will
be executed n...
|
by: Michael Bulatovich |
last post by:
I have a very simple db I use for keeping track of hours, tasks, projects,
clients etc. It has a form that I use to enter data. Currently the form has
a textbox for a field called "start time",...
|
by: Carlos |
last post by:
Hi all,
I have used the datetime class, but I just came up with a situation
that need to have some advise. If I now how much time have passed,
can I know the original date?. Lets say that I know...
|
by: vashwath |
last post by:
Hi all,
I have written program for calculating the execution time of a
function.Any critics (on the method of calculating execution time) are
welcome.
#include <stdio.h>
#include <time.h>...
|
by: Ravi Ambros Wallau |
last post by:
Hi:
We developed a set of ASP.NET Web Applications that never runs in
stand-alone mode, but always inside a portal (Rainbow Portal). All modules
are copied on that portal.
My question is: load...
| |
by: ret4rt |
last post by:
Hello.
I have a task to do which is as follows:
I have to do an "id query" on a primary key of my db and then calculate the response time of the query.
Task says that i'm able to take screenshots...
|
by: Umesh |
last post by:
i want to calculate the time required to execute a program. Also i
want to calcute the time remaining for the execution of the program.
how can i do that?
pl mention some good websites for...
|
by: James Turk |
last post by:
Hi,
I have a situation where I have some class members that should only be
done once. Essentially my problem looks like this:
class Base(object):
dataset = None
def __init__(self, param):...
|
by: anto.anish |
last post by:
Hi -
I have been using clock() for calculating CPU time and time() for
calculating Wall time. However, since time() does not provided milli/
microsecond accurancy, i started using...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |