-1
我有這個代碼用於計算兩個輸入字段之間的日期差異(沒有周末),並在第三個文本框中以天顯示差異。日期格式是yy-mm-dd(因爲mysql)。jquery日期差異
<script type="text/javascript">
$("#vazi_od, #vazi_do").change(function() {
var d1 = $("#vazi_od").val();
var d2 = $("#vazi_do").val();
var minutes = 1000*60;
var hours = minutes*60;
var day = hours*24;
var vazi_od1 = getDateFromFormat(d1, "yy-mm-dd");
var vazi_do1 = getDateFromFormat(d2, "yy-mm-dd");
var newvazi_od=new Date();
newvazi_od.setFullYear(vazi_od1.getYear(),vazi_od1.getMonth(),vazi_od1.getDay());
var newvazi_do=new Date();
newvazi_do.setFullYear(vazi_do1.getYear(),vazi_do1.getMonth(),vazi_do1.getDay());
var days = calcBusinessDays(newvazi_od,newvazi_do);
if(days>0)
{ $("#razlika").val(days);}
else
{ $("#razlika").val(0);}
});
</script>
但是,當我選擇開始和結束日期,沒有發生在應該顯示天差異的字段...任何幫助?
另外,jquery的日期格式設置爲yy-mm- dd – itsamemario 2012-07-07 17:44:59
您有語法錯誤。至少關閉'})'丟失。 – Gumbo 2012-07-07 17:47:13