mysql - Php Time Format -


i have here mysql query average of column(the column data type 'time'). column values example are: 00:00:55, 00:00:59, 00:01:03

select avg(time_to_sec(column_name)) table_name)as average_result 

in php formatted result way:

<?php foreach($display_average $da){      echo date("h:i:s", ($da["average_result"])); } ?> 

outputs: 08:00:59 instead of 00:00:59, why starts 08? or did miss something? thanks!

both php's date/time functions , mysql's date/time data types handle wall clock timestamps, not durations; i.e. 00:00:55 means fifty-five seconds past midnight. not want; couldn't handle durations longer 23 hours, 59 minutes, 59 seconds, because data types , functions you're using handling clock time, cannot exceed these values.

your specific issue stems timezone settings. larger issue need store simple integer values expressing elapsed seconds or minutes; not timestamps. format human readable string in php can use dateinterval class.


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -