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?
Be careful with
date(). it expects to be provided with a PHP timestamp, which is number of seconds since midnight, Jan 1/1970. It will "work" for small timestamp values, but will get increasingly wrong as you pass in "larger" timestamps, as you will be dealing with months/days/years in 1970, plus leapyears, etc...As for the conversion, what's wrong with it? 4.48333... is 4 full minutes, and 0.483333 is simply 29/60.