我date = 12/06/2017(mm/dd/yyyy)
和时间02:11
。
代码如下
var date=$('#datepicker_reservation').val();// returns date
var time=$('#timePicker_reservation').val();// returns time
帮助...提前致谢
答案 0 :(得分:1)
你可以试试这个:
var rdate = $('#datepicker_reservation').val().split('/');
var rtime = $('#timePicker_reservation').val();
var newdt = rdate[2]+'-'+rdate[0]+'-'+rdate[1]+' '+rtime;
答案 1 :(得分:0)
function fnclick()
{
var date= "12-04-2017"
var time=" 05:12 PM"
var date = formatDate(new Date(date + time))
$("#div1").html('').html(date);
alert(date);
}
function formatDate(date) {
try {
var hours = date.getHours();
var minutes = date.getMinutes();
var ampm = hours >= 12 ? 'PM' : 'AM';
hours = hours % 12;
hours = hours ? hours : 12; // the hour '0' should be '12'
minutes = minutes < 10 ? '0' + minutes : minutes;
var strTime = hours + ':' + minutes + ' ' + ampm;
return date.getMonth() + 1 + "-" + date.getDate() + "-" + date.getFullYear() + " " + strTime;
} catch (e) {
}
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="div1">
</div>
<button onclick='fnclick()'> show me date</button>
&#13;