Store the time of an input type Time field in a Time type column

Asked

Viewed 445 times

0

I am working on a website that schedules real estate surveys, and I need to store in Mysql the time the person requested the visit. I am using an HTML input field of the Time type.
inserir a descrição da imagem aqui
The field in the table is in the time data type with length 6.
inserir a descrição da imagem aqui
When I try to insert via SQL, via AJAX, it is not working.
I believe you have something related to time value formatting...
Can someone help me and guide how I should proceed to effect value insertion?

$txtDataVistoria_formatada = date("Y-m-d", strtotime($txtDataVistoria));

$txtHoraVistoria_pre = new DateTime($txtHoraVistoria);
$txtHoraVistoria_formatada = $txtHoraVistoria_pre->format('H:i:s.u');
  • To $txtHoraVistoria=14:30 with $txtHoraVistoria_formatada = date( 'H:i:s.u', strtotime($txtHoraVistoria) ); we will have the result 14:30:00.000000 Question: what is the purpose of this precision in the format s.u?

  • I defined it this way because I thought that when manually inserting via phpmyadmin it provides this accuracy, I thought that via PHP code should pass the same level of microsecond accuracy... But I really don’t know if this is right.

  • My database (Mysql) for time column only accepts this format 14:30:00

  • In mine when I click to manually insert via PHP it opens a slider for each digit (hour, min, sec, miliseg, microseg)... I’ll upload a picture later...

  • Which bank?

  • Maria DB https://mariadb.com/kb/en/library/microseconds-in-mariadb/

  • Mysql from Oracle

  • In mine it opens like this https://i.stack.Imgur.com/wQqHi.png

  • That’s right except mine has Mili and micro seconds

  • Your phpmyadmin version should be more current, but qq way I think Mysql does not accept Mili and micro

  • All right, I don’t want to. I just need to store the hour is the minute... How to do?

  • Just do the Insert with the value returned via POST. It will store the hour the minute and break the 00 of the seconds automatically

  • In your case it should be $txtHoraVistoria then I would be $txtHoraVistoria=$_POST['Name_Input']

  • Thank you Leo! I will try to make this way the evening and give you a feedback! Thanks for the help!

Show 9 more comments
No answers

Browser other questions tagged

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