To change the format of the date and time displayed in the input field, you can use JavaScript to manipulate the value of the input field.
<input type="datetime-local" class="form-control" name="booking_checkin" id="booking_checkin">
<script>
// Get the input field element
const input = document.getElementById('booking_checkin');
// Add an event listener to the input field to detect when the value changes
input.addEventListener('change', (event) => {
// Get the value of the input field
const value = event.target.value;
// Convert the value to a Date object
const date = new Date(value);
// Format the date and time using the toLocaleString method
const formattedDate = date.toLocaleDateString('en-US', { year: 'numeric', month: '2-digit', day: '2-digit' });
const formattedTime = date.toLocaleTimeString('en-US', { hour12: false, hour: '2-digit', minute: '2-digit' });
// Set the value of the input field to the formatted date and time
event.target.value = `${formattedDate}, ${formattedTime}`;
});
</script>
This code listens for the change event on the input field and then formats the value using the toLocaleString method of the Date object. The formatted date and time are then set as the value of the input field.
Note that this code assumes that the user's browser is set to the en-US locale. If your application supports multiple locales, you may need to adjust the arguments to the toLocaleDateString and toLocaleTimeString methods accordingly.
new Date
to get anything you want – Cardona