note 58977 added to function.fmod
| From: | cory at simplesystems dot ca | Date: | Wed, 23 Nov 2005 01:39:56 +0000 |
| Subject: | note 58977 added to function.fmod | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-98946@lists.php.net to get a copy of this message | ||
Just a note on the previous note by Ryan Means:
Instead of using explode() to get the number before the decimal point, would be to use floor()...
floor() rounds fractions down, which is exactly what is needed.
His same example using floor();
<?PHP
$totalsec=XXXXXXX; //Replace the X's with a int value of seconds
$daysarray = floor( $totalsec/86400 );
$partdays = fmod($totalsec, 86400);
$hours = floor( $partdays/3600 );
$parthours = fmod($partdays, 3600);
$min = floor( $parthours/60 );
$sec = fmod($parthours, 60);
echo "days " . $days . "<br>";
echo "hours " . $hours . "<br>";
echo "minutes " . $min . "<br>";
echo "seconds " . $sec . "<br>";
?>
----
Manual Page -- http://www.php.net/manual/en/function.fmod.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+58977
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58977&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58977&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58977&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58977&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58977&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58977&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58977&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+58977&report=yes
Search -- http://master.php.net/manage/user-notes.php