MySQL storing duration time – datatype?

Storing it as an integer number of seconds will be the best way to go.

  • The UPDATE will be clean and simple – i.e. duration = duration + $increment
  • As Tristram noted, there are limitations to using the TIME field – e.g. “TIME values may range from '-838:59:59' to '838:59:59'
  • The days/hours/minutes/seconds display formatting won’t be hardcoded.
  • The execution of your other calculations will almost surely be clearer when working with an integer “number of seconds” field.

Leave a Comment