Do you know guys how display the date value from database to datetimepicker field?
the example value from database is 2022-10-31
<div id="allDay" data-target-input="nearest">
<input type="text" id="all-value" name="all_day"
data-target="#allDay"
value="" />
<div data-target="#allDay" data-toggle="datetimepicker">
<div ><i ></i></div>
</div>
</div>
js
$('#allDay,#startLongDay,#endLongDay').datetimepicker({
format: 'L',
minDate: new Date()
});
CodePudding user response:
If you're using the jQuery DateTime Picker, You can retrieve the value from the database and then pass it to the view through your controller. After that, you can set it as the value
attribute.
Example:
<input type="text" id="all-value" name="all_day"
data-target="#allDay"
value="{{$date}}" />
Or else you can do it in JS Way:
- Setting with
viewDate
option
<script>
var d = "{{$date}}"
$('#allDay,#startLongDay,#endLongDay').datetimepicker('viewDate', d);
</script>
- Setting with
date
option
<script>
var d = "{{$date}}"
$('#allDay,#startLongDay,#endLongDay').datetimepicker('date', d);
</script>
Please note that in all of the above steps you need to format the date correctly.