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.
The field in the table is in the time data type with length 6.
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 result14:30:00.000000
Question: what is the purpose of this precision in the formats.u
?– user60252
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.
– Fernando Ferrari Fernandes
My database (Mysql) for time column only accepts this format
14:30:00
– user60252
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...
– Fernando Ferrari Fernandes
Which bank?
– user60252
Maria DB https://mariadb.com/kb/en/library/microseconds-in-mariadb/
– user60252
Mysql from Oracle
– Fernando Ferrari Fernandes
In mine it opens like this https://i.stack.Imgur.com/wQqHi.png
– user60252
That’s right except mine has Mili and micro seconds
– Fernando Ferrari Fernandes
Your phpmyadmin version should be more current, but qq way I think Mysql does not accept Mili and micro
– user60252
All right, I don’t want to. I just need to store the hour is the minute... How to do?
– Fernando Ferrari Fernandes
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
– user60252
In your case it should be
$txtHoraVistoria
then I would be$txtHoraVistoria=$_POST['Name_Input']
– user60252
Thank you Leo! I will try to make this way the evening and give you a feedback! Thanks for the help!
– Fernando Ferrari Fernandes