et4891 Posted March 3, 2013 Share Posted March 3, 2013 Hi, I'm creating a script and let's say I have a user/pass to enter and once it's entered another page will be redirected and in that page will show a line sayingi you have been staying here for xxx seconds. I'm using $_SESSION at the moment but I'm not sure how to set up so time() will start counting after logged in. Quote Link to comment https://forums.phpfreaks.com/topic/275149-how-to-use-time-to-count-how-many-seconds-you-were-here/ Share on other sites More sharing options...
Solution requinix Posted March 3, 2013 Solution Share Posted March 3, 2013 You don't "start counting" anything. Record when the logged in, then every page (or whenever) you do time()-that value to get the number of seconds elapsed. (Then reformat into hours/minutes/seconds/whatever if you want something better looking.) Quote Link to comment https://forums.phpfreaks.com/topic/275149-how-to-use-time-to-count-how-many-seconds-you-were-here/#findComment-1416131 Share on other sites More sharing options...
et4891 Posted March 3, 2013 Author Share Posted March 3, 2013 You don't "start counting" anything. Record when the logged in, then every page (or whenever) you do time()-that value to get the number of seconds elapsed. (Then reformat into hours/minutes/seconds/whatever if you want something better looking.) hehe that's what I did but I realized I put it the script into the wrong .php script file Quote Link to comment https://forums.phpfreaks.com/topic/275149-how-to-use-time-to-count-how-many-seconds-you-were-here/#findComment-1416134 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.