The issue is that the input type "date" automatically formats the date in the "mm/dd/yyyy" format, regardless of the format specified in the PHP code. To display the date in the desired format, you can use JavaScript to format the date after it is loaded into the input field.
Here's an example of how to do this using jQuery:
$(document).ready(function() {
// Get the value of the input field
var startDate = $('#inputStart_date').val();
// Convert the date to the desired format
var formattedDate = moment(startDate, 'YYYY-MM-DD').format('YYYY/MM/DD');
// Set the value of the input field to the formatted date
$('#inputStart_date').val(formattedDate);
});
This code uses the Moment.js library to convert the date to the desired format. You'll need to include the Moment.js library in your project for this code to work.
Alternatively, you can use the HTML5 date input with a custom format. Here's an example:
<input type="text" name="start_date" value="{{ $competition->start_date ? $competition->start_date->format('Y-m-d') : '' }}" class="form-control @error('start_date') is-invalid @enderror" id="inputStart_date" placeholder="Enter Start Date" pattern="\d{4}/\d{2}/\d{2}" title="Enter a date in the format YYYY/MM/DD">
This code uses a regular expression pattern to enforce the format "YYYY/MM/DD" on the input field. The "title" attribute provides a hint to the user about the expected format. Note that this approach will not work in all browsers, so you may need to use a JavaScript solution as well.