Time addition not working in PHP -
Time addition not working in PHP -
i have assigned variable as
$tot_time=strtotime("h:i:s", time());
then add together time using loop with:
$tot_time= strtotime($tot_time)+strtotime($result_row->time);
then, print total time after loop using:
echo date("h:i:s",$tot_time);
i lastly values loop.
you're badly abusing strtotime(). why not leave time values integers are?
$tot_time += strtotime($result_row->time);
$tot_time already integer, there literally no point in running through strtotime(). , can't utilize method adding time intervals. php's date scheme works on timestamps, seconds-since-1970.
if $tot_time naturally exceeds 24 hours, you're going "tomorrow" time, e.g. yon't "25 hours", you'll "1 day , 1 hour". you'll print out "1hour", , time interval very wrong.
php time addition
Comments
Post a Comment