| How long a user is logged in for 
 
	 
	
		| Author | Message |   
		| Kazz 
 
 
 
 
 | 
			
				|  Posted: 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
 
  
   |  |   
		|  |   
		| RandomLetters 
 
 
 
 
 | 
			
				|  Posted: 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 
 
  
 
 
 | 
			
				|  Posted: 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 
 
 
 
 
 | 
			
				|  Posted: 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. |  
				|  |  |   
		|  |  |  
	  
		|  |   
		|  |  
 |