You are here: Re: TIME calculation please :-/ « All PHP « IT news, forums, messages
Re: TIME calculation please :-/

Posted by Steve on 09/24/07 00:24

"Beshoo" <basheermoro@gmail.com> 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]);
}

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация