Recommendations on Storing Time in MySQL

  • Filter
  • Time
  • Show
Clear All
new posts

  • Recommendations on Storing Time in MySQL

    I would like to get some advice on storing time columns in MySQL.

    We are developing a time sheet application that requires us to store checkin, checkout times, breaks in hours and minutes, but later carry out computations in decimal.

    Should I use:
    - time columns and use mysql time functions for the computations
    - store the time as an integer (number of seconds since 1970 or number of hours) then show the hour/minute only for display purposes

    Thanks in advance

  • #2
    I would use MySQL's native time types and functions, because they work fine and it's going to be a big mess if you code it yourself. But I am not sure if you need higher resolution than one second, given your mention of decimal. If so, you can use MariaDB.


    • #3
      Thanks, that was the approach I had used initially and will follow that through.