How can I write a Datetime-Local HTML input to the database with the Datetime type Field?

Asked

Viewed 143 times

0

In the project I am developing in PHP I need one in a registration form. I wanted to know how I can save this data in the database, I tried to use the type Datetime in MYSQL, but this type has the layout of hours:minutes:seconds already uses the type hours:minutes. If anyone can shed some light, thank you very much. I really need the bank to have a date and day together, not separate, as it would be the right thing to do.

  • Mysql datetime stores the date and time, and dates have no format. If you make a select, the seat can even display in the format "dd/mm/yyyy hh:mm:ss" or any other, but this does not mean that the date is in that format. The bank only keeps the date/time values and that’s what you should be worried about. The format is not part of the date itself. If you want to display the date in a specific format, do the conversion in PHP

  • I just did the conversion, it was much easier than I expected, I thought about this function returning home by bus, I just needed to see how the Datetime-local passed the value, Normal date: 2019-04-05T12:12 ai é só usar o str_replace para tirar esse T e colocar um espaço, e colocar o "00" at the end with concatenation, so I can record in the bank quietly. My project takes very little time and I didn’t want to get my hands on the Jquery and JS calendar, I just needed this MYSQL Datetime because of this calendar.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.