开发者

Timestamp intervals processed by date() don't calculate correctly

开发者 https://www.devze.com 2023-03-27 02:42 出处:网络
I have two unix timestamps in my database that I am subtracting to get a time interval in seconds: $interval = $array[\"time2\"] - $array[\"time1\"]; // 开发者_如何学GoWhen echoed, $interval = 3

I have two unix timestamps in my database that I am subtracting to get a time interval in seconds:

$interval = $array["time2"] - $array["time1"]; // 开发者_如何学GoWhen 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消