Reputation: 44699
I have two unix timestamps in my database that I am subtracting to get a time interval in seconds:
$interval = $array["time2"] - $array["time1"]; // When echoed, $interval = 3
However, when I run this $interval through date()
, like so:
echo date("g\h i\m", $interval);
these 3 seconds all of a sudden echo to:
7h00m
Does anyone have any idea why date() might be taking these three seconds and stretching them out into a 7 hour interval somehow?
Upvotes: 0
Views: 137
Reputation: 164795
The second argument to date()
is a timestamp (seconds since midnight, Jan 1, 1970 GMT). Your interval is probably equating to 7am in your timezone relative to this date.
Upvotes: 2