Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 How long a user is logged in for
Index -> General Programming
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Kazz




PostPosted: Sun May 08, 2011 10:38 pm   Post subject: How long a user is logged in for

I need help with this.. I want to be able to keep track of how long a user is 'Logged' into my site. So far i only can get seconds. I subtract logged in time from logged out time and i want days, hours, minutes, seconds, ect.. If anyone has any sugestions it would be greatly apreciated.
Sponsor
Sponsor
Sponsor
sponsor
RandomLetters




PostPosted: Sun May 08, 2011 10:58 pm   Post subject: RE:How long a user is logged in for

Well, minutes = 60 seconds, hours = 60 minutes, and so on. You can just record in seconds and calculate it when you display it.
Zren




PostPosted: Mon May 09, 2011 12:14 am   Post subject: RE:How long a user is logged in for

If you're using php, something like this ought to work.

http://www.php.net/manual/en/dateinterval.format.php

php:

<?php

$january = new DateTime('2010-01-01');
$february = new DateTime('2010-02-01');
$interval = $february->diff($january);

// %a will output the total number of days.
echo $interval->format('%a total days')."\n";

// While %d will only output the number of days not already covered by the
// month.
echo $interval->format('%m month, %d days');

?>

Look at the DateTime constructor if you're calculating from a unix timestamp.

http://www.php.net/manual/en/datetime.construct.php
Kazz




PostPosted: Mon May 09, 2011 8:47 am   Post subject: Re: How long a user is logged in for

Alright i will try something like that.
Display posts from previous:   
   Index -> General Programming
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: