PHP's date usage results in 2 hours error -
i'm using date('h:i:s', (time() - $start['time'])) displa time passed since start of script.
whatever result of time() - $start['time'] - 0, 17 or whatever date prints out 02:00:00, 02:00:17 etc.
what may reason?
time returns absolute numeric timestamp, numeric value 2012-06-04 16:35:12. start time similar numeric, absolute timestamp. subtracting 1 other result in small number, is, again, absolute timestamp. time around beginning of 1970. when format timestamp using date('h:i:s'), display time portion of timestamp 1970-01-01 02:00:00.
read unix timestamps represent.
the time difference you're looking result of time() - $start['time'], in seconds, can't format using date(). more along lines of:
$diff = time() - $start['time']; echo 'difference in seconds: ' . $diff; echo 'difference in minutes: ' . $diff / 60; echo 'difference in hours: ' . $diff / 60 / 60;
Comments
Post a Comment