gpt4 book ai didi

javascript - 如何从 Bootstrap Datepicker 中删除年份

转载 作者:行者123 更新时间:2023-12-02 21:48:46 25 4
gpt4 key购买 nike

我正在使用这个引导日期选择器:https://bootstrap-datepicker.readthedocs.io/en/v1.9.0/index.html

HTML 代码:

<div id="datepicker" data-date="12/03/2012"></div>
<input type="hidden" id="my_hidden_input">

JS 代码:

$('#datepicker').datepicker({
format : 'MM'
});

$('#datepicker').on('changeDate', function() {
$('#my_hidden_input').val(
$('#datepicker').datepicker('getFormattedDate')
);
});

现在,它显示月份和年份。例如:2020 年 2 月

如何删除年份?

enter image description here

最佳答案

你应该这样做:

$('#datetimepicker1').datetimepicker({
format: 'L',
dayViewHeaderFormat: 'MMMM'
});
<link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css" rel="stylesheet"/>
<link href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/css/bootstrap-datetimepicker.css" rel="stylesheet"/>

<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.17.1/moment-with-locales.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.min.js"></script>

<div class="input-group date" id="datetimepicker1">
<input type="text" class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>

关于javascript - 如何从 Bootstrap Datepicker 中删除年份,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60181288/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com