我正在使用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>
答案 0 :(得分:1)
试试这个
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>