I want to display the current full date and time, but 5 minutes earlier than it actually is. How would I go about doing this? Thanks!
for the time minus 5 minutes use: print date("h").":".(date("i")-5);
The rest you probalby already have.
look at the date funcrtion on php.net: http://us3.php.net/manual/en/function.date.php
It shows how to do lots with the date.
Just out of curiosity...why do you want the exact time five minutes ago?
I'm sure this isn't the easiest way to do this, but I have a members system on my website and I want to display the active users over the past five minutes. So in my database I have the last active datetime field for each user, then I check to see if that date is bigger (or smaller) than the date five minutes ago. I'm hoping this will work (I'm open to suggestions though!)
About your code, would that work if the actual time was, say "7:02" because wouldn't that code then produce "7:-57" or am I wrong and you are right?
echo date("H:i:s",time()-300); Where 300 is 300 seconds less than server time!
Thanks, okuto1973. That's better tha my quick reply, which would provide negative minutes.
This will work fine, too: date("H:i:s",strtotime("-5 minute"))