TIME calculation please :-/
am 23.09.2007 06:02:16 von Beshoo
TIME calculation please :-/
hi gaiz !!
just aim trying to make a fucntion to calculate a period of time
aim making trfic website analysis I mean for example i must know
when a user is logedon and logedOut So i can know the period he
has spent in the site !!! ??
Ofcourse i have the to time[when he login and logout] i am tring to
make fucntion to caleculate the period between thes 2 time !!!!
fore example i have loged in at :
12:30
and logged out at :
1:10
there must be 40 mints !!??
i wirte my script bt it has alot of problems!!
thanx in advance !!
Re: TIME calculation please :-/
am 23.09.2007 09:12:28 von Shion
Beshoo wrote:
> TIME calculation please :-/
>
> hi gaiz !!
> just aim trying to make a fucntion to calculate a period of time
> aim making trfic website analysis I mean for example i must know
> when a user is logedon and logedOut So i can know the period he
> has spent in the site !!! ??
> Ofcourse i have the to time[when he login and logout] i am tring to
> make fucntion to caleculate the period between thes 2 time !!!!
>
> fore example i have loged in at :
>
> 12:30
> and logged out at :
> 1:10
>
> there must be 40 mints !!??
> i wirte my script bt it has alot of problems!!
quite simply you could convert the two times to unixtime and then:
unixtime_logout - unixtime_login = seconds between login and logout
then you have only to convert the seconds to days/hours/minutes/seconds
--
//Aho
Re: TIME calculation please :-/
am 24.09.2007 02:24:57 von Steve
"Beshoo" wrote in message
news:1190520136.273814.23720@19g2000hsx.googlegroups.com...
> TIME calculation please :-/
>
> hi gaiz !!
gaiz? as in pronunciation, 'gays'?
> just aim trying to make a fucntion to calculate a period of time
> aim making trfic website analysis I mean for example i must know
> when a user is logedon and logedOut So i can know the period he
> has spent in the site !!! ??
you'll have a heck of a time getting determining when someone 'logged out'.
you'll have to come up with a scheme to do that...one that says here is a
significant gap in time, i suppose the last page visited was when they left
the site since the last log in.
do *you* ever log out of a site, or do you just leave? i certainly don't
bother to log out.
> Ofcourse i have the to time[when he login and logout] i am tring to
> make fucntion to caleculate the period between thes 2 time !!!!
>
> fore example i have loged in at :
>
> 12:30
> and logged out at :
> 1:10
>
> there must be 40 mints !!??
> i wirte my script bt it has alot of problems!!
oh, you mean "a lot". "alot" isn't a word..."allot" is, however you
aren't assigning or setting anything aside in the context of the sentence.
but, i digress...
>
> thanx in advance !!
once you get all your stuff in place, here's a standard dateDiff
function...it's not much from there to get a function to say 'n day(s), n
hour(s), n minute(s)', if you need that. but, here's the basic function:
function dateDiff($firstDate, $secondDate, $interval = 'd')
{
$intervals = array(
'y' => (365.25 * 24 * 60 * 60) ,
'm' => (30 * 24 * 60 * 60) ,
'w' => (7 * 24 * 60 * 60) ,
'd' => (24 * 60 * 60) ,
'h' => (60 * 60) ,
'n' => 60 ,
's' => 1
);
return floor(abs($firstDate - $secondDate) / $intervals[$interval]);
}