Re: Convert time

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



PHP is typeless and will convert your left hand operand to the type
returned by your right hand expression. You can deal with this by
casting the right hand expression to an integer when computing the
minutes. To compute the seconds, you better use the modulus operator(%).

Example:

$min = (int)($sec/60);
$min = $sec % 60;

There might be also a floor function you can instead of casting, but of
that I know nothing (read: I didn't search the man pages).

On Mon, 2004-02-16 at 17:35, Harpreet wrote:
> I am trying to add time. If my seconds or minutes go over 60 how can i find
> the number of minutes or hours.
> 
> I am doing something like this
> 
>  if ($totsec>60)
>   {
>     $min=$totsec/60;
>     $sec=$totsec-$min*60;
>   }
> 
> but i get results in 1.233333333.
> 
> I need integers
> 
> Please help

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux