Reputation: 1457
I have an update form with html5
elements to update a row of data from table. All the elements are showing the current corresponding data in table except the datetime-local
input
element. Even the date
, week
and month
element are working.
The data for that field is saved in database in a column with datetime
type. This is a sample of data stored in that column.
2014-05-15 12:58:00
How can I make the datetime-local
input
element to show the current value on database. Do I have to format this value in some other way for that ( like d/m/Y H:i a
or something)
Here is the code for that element
$html_form .= "<tr><td class='form_left'>".$label." : </td><td class='form_right'><input type='datetime-local' name='birth_day' id='birth_day' value='".$row_data['birth_day']."' /> </td></tr>";
Need to solve this issue as fast as possible. I am stuck with it right now.
Please help me find a solution. I can't finish my current project without fixing it.
Upvotes: 0
Views: 3254
Reputation: 1457
Reformatted the datetime
data in the table with the following code.
$birth_day = strftime('%Y-%m-%dT%H:%M:%S', strtotime($row_data['birth_day']));
Then provided that reformatted value as the value of datetime-local
input
element.
$html_form .= "<tr><td class='form_left'>".$label." : </td><td class='form_right'><input type='datetime-local' name='birth_day' id='birth_day' value='".$birthday."' /> </td></tr>";
Then it started showing the current value from database.
Upvotes: 5