gpt4 book ai didi

javascript - 仅获取 Bootstrap 日期分页器中选定的日期

转载 作者:行者123 更新时间:2023-11-27 22:37:19 25 4
gpt4 key购买 nike

我正在使用 bootstrap-datepaginator Source .

以下代码返回此格式的日期 Sun Aug 14 2016 00:00:00 GMT+0400

相反,我想以这种格式返回它14/Aug/2016

    <script>
$(document).ready(function () {
var options = {
selectedDate: '2016-01-01',
selectedDateFormat: 'YYYY-MM-DD'
}

$('#paginator').datepaginator(options);

$('#paginator').datepaginator();

$('#paginator').on('selectedDateChanged', function (event, date) {
// Your logic goes here
alert(date);
});
});</script>

最佳答案

试试这个

var months = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", 
"Jul", "Aug", "Sep", "Oct", "Ntove", "Dec" ];


var dati = "Sun Aug 14 2016 00:00:00 GMT+0400";


var date = new Date(dati);
var thedate = date.getDate();
var themonth = date.getMonth();
var theyear = date.getFullYear();

alert(thedate);
alert(themonth);
alert(theyear);

var newdate = thedate +"/"+months[themonth]+"/"+theyear;
alert(newdate);

工作示例

<html>
<head></head>
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<body>



</body>

<script type="text/javascript">

var months = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Ntove", "Dec" ];


var dati = "Sun Aug 14 2016 00:00:00 GMT+0400";


var date = new Date(dati);
var thedate = date.getDate();
var themonth = date.getMonth();
var theyear = date.getFullYear();

alert(thedate);
alert(themonth);
alert(theyear);

var newdate = thedate +"/"+months[themonth]+"/"+theyear;
alert(newdate);







</script>

</html>

关于javascript - 仅获取 Bootstrap 日期分页器中选定的日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39000855/

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