1

i want to get the current time and set it to a variable . after that i want to get the current time and subtract the variable from it . this way i can get the elapsed time. can anyone help ? Edit: wihtout the use of a database.. is this possible?

$firsttime = time();  #ofcourse this is going to update to current time 
#which is my problem

$diff = time() - $firsttime;
echo "<br>";
echo "<br>";
echo "You visited this page ",$diff," seconds ago";
dadu300
  • 11
  • 3

1 Answers1

0

It appears you are running two time() functions one right after the other, therefore the difference is in milliseconds. I believe what you want to do is store a cookie on the browser or store the time in a session (firsttime) and compare that value on the subsequent request.

You may then wish to update that cookie/session to the new time so you can see the time differences between page visits.

On the final line, shouldn't those commas be periods?

eleete
  • 86
  • 6