I'm running into a discrepancy with either my conversion of an integer into defined Minutes.
<?php
$seconds = 269;
echo date("G:i:s", $seconds);
// result: 0:04:29
?>
I figured I'd double check on some sites to see if the conversion is correct:
Here's one I found: http://www.thecalculatorsite.com/conversions/time.php
The result returned is: 4.4833333333333
Example 1 returns: 0:04:29 Example 2 returns: 4.4833333333333
I'm confused about this.
What am I missing here. Am I using the date()
function incorrectly?
You can use DateTime class for time calculation:
Code:
Output:
As you can see in output, you have all the info you need. To access it, just use
$diff->i
for minutes,$diff->s
for seconds etc.