如何使用jqueryui更改laravel 8中的日期选择器格式



我正在用laravel 8构建一个应用程序,并使用jqueryui,我在日期选择器格式方面遇到了问题,因为它的格式是"mm/dd/yyyy";我希望它是";dd/mm/yyyy";只是在视图中,而不是数据库,因为它刚刚插入数据库中,没有问题。

我尝试添加data-date-format="dd/mm/yyyy",但没有成功,我也尝试添加

<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$( function() {
$('#datepicker').datepicker({
format: 'dd/mm/yyyy'
});        
});
</script>

但也没用!

这是我使用的输入代码

<input type="date" id="datepicker" class="form-control" name="first_visit_date" value="{{ $owner->first_visit_date }}" data-date-format="dd/mm/yyyy">

我做错什么了吗?

请尝试将格式更改为dateFormat。

示例代码:

<input type="text" id="txtDate" name="SelectedDate" readonly="readonly" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js" type="text/javascript"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"
type="text/javascript"></script>
<link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css"
rel="Stylesheet" type="text/css" />
<script type="text/javascript">
$(function () {
$("#txtDate").datepicker({
showOn: 'button',
buttonImageOnly: true,
buttonImage: 'images/calendar.gif',
dateFormat: 'dd/mm/yy'
});
});
</script>

最新更新