0

I have this php code

$DayJobTime = ($JobEnd - $JobStart - $Break) * 60;
echo "$DayJobTime";

and i get the correct answer - 480 minutes, but for me show Notices "Notice: A non well formed numeric value encountered in " 3 times

JobEnd, JobStart and Break i get from datebase and it looks like this

JobEnd -   08:00:00
JobStart - 17:00:00
Break -    01:00:00

How can I fix it?

O. Jones
  • 103,626
  • 17
  • 118
  • 172
Andrius
  • 1
  • 1
  • Arithmetic operators can only be done on numbers. `08:00:00` is not a number. – Barmar May 20 '18 at 12:45
  • PHP just parses the beginning, `17:00:00` is treated as just `17`, but you get the warning because of the extra. – Barmar May 20 '18 at 12:47
  • how can I calculate differently? – Andrius May 20 '18 at 12:48
  • Convert your time strings to integer numbers of seconds, then perform the calculation using those numbers. Read this. https://stackoverflow.com/questions/4834202/convert-time-in-hhmmss-format-to-seconds-only – O. Jones May 20 '18 at 12:51
  • Use `explode(':', $JobEnd)` to convert it to an array, then the minutes is `60 * $array[0] + $array[1]`. – Barmar May 20 '18 at 12:57

0 Answers0