This question already has an answer here:
How do I change the date format using PHP? I have used the following code but it is displaying the date input field value as m-d-Y. Why it is changing the format?
$effectivedate = date('M-d-Y', strtotime($empCompensationdata-effective_date));
$effective_date = date('Y-m-d', strtotime($empCompensationdata-effective_date));
$("#effective_date").val($effectivedate);
$('#effective_date').attr('data-value', $effective_date);
</div>
The reason the value is displayed as M-d-Y is because that's what you're assigning to it with the val() method:
$effectivedate = date('M-d-Y', strtotime($empCompensationdata->effective_date));
$effective_date = date('Y-m-d', strtotime($empCompensationdata->effective_date));
$("#effective_date").val($effectivedate); //This variable contains "M-d-Y"
$('#effective_date').attr('data-value', $effective_date);
So if you want to have Y-m-d, just change the assigning variable:
$("#effective_date").val($effective_date); //This variable contains "Y-m-d"