0

I need to calculate rally results table in PHP. So i have varchar string column in the mysql db in 'mm:ss:milliseconds' format ('03:54:78' for example).

How can i do the ($time1 + $time2) and ($time1 - $time2) operations in PHP ?

juergen d
  • 201,996
  • 37
  • 293
  • 362
Trimod
  • 114
  • 1
  • 5
  • 1
    First of all change you column type to `TIME` – juergen d Jun 17 '14 at 16:38
  • it's a string. tear it apart into its constituent bits, and then it's just simple math. – Marc B Jun 17 '14 at 16:41
  • You can use **explode()** function and convert it to miliseconds and make operations with them and finally convert it back. But better idea is, save it as number of miliseconds directly in database. – Unlink Jun 17 '14 at 16:49
  • @juergen-d , I cant use TIME type because ti truncates value for seconds more than 60. Milliseconds can be up to 99. – Trimod Jun 17 '14 at 17:01

0 Answers0