The essence is this: There is a form on the site. There are fields in the form: wake-up time wake-up time These are fields of the hh: mm format. It is necessary to enter the field value in the database, I can’t understand what type of field in the database should be and how to transfer the time value to them.

upd1: thanks, varcharom added. Now I will think how to continue to work with this data.

  • The field type in the database is either lower case varchar or time, depending on your further operations on this date. - Jean-Claude
  • In the future, I plan to collect time data and calculate the average. Then along the way there was another question, if I convey in the hh: mm format, I won’t calculate the average on the fly. Do I understand correctly that it will be possible to pull time values ​​from the database, translate them into milliseconds, for example, and work with them? - Dan Dark
  • @DanDark Why milliseconds when you can simply translate them into seconds. Using the explode function, get the value of hours and minutes and work with them - $ time = explode (':', time_value); - alexkad

1 answer 1

Isn't it easier to store in timestamp format in MySQL? Then, when you work with the base, you get a fairly extensive toolkit for dates \ time. You can even record with the date and then you can further build various schedules on this matter. And you can simply put the data there with the "yyyy.mm.dd hh: mm" line.