2011-10-20 69 views
0

我使用的JavaScript的倒計時器JavaScript的倒計時新的日期

<script type="text/javascript"> 
     $(function() { 
     var newYear = $(".HF").val(); 
      alert('hehe' + newYear); 
      $('#countdown').countdown({ until:newYear, format: 'DHMS', layout: 
'<div id="timer">' + '<hr />' + 
    '<div id="timer_days" class="timer_numbers">{dnn}</div>' + 
    '<div id="timer_hours" class="timer_numbers">{hnn}</div>' + 
    '<div id="timer_mins" class="timer_numbers">{mnn}</div>' + 
    '<div id="timer_seconds" class="timer_numbers">{snn}</div>' + 
'<div id="timer_labels">' + 
    '<div id="timer_days_label" class="timer_labels">days</div>' + 
    '<div id="timer_hours_label" class="timer_labels">hours</div>' + 
    '<div id="timer_mins_label" class="timer_labels">mins</div>' + 
    '<div id="timer_seconds_label" class="timer_labels">secs</div>' + 
'</div>' + 
'</div>' 
      }); 
     }); 
</script> 

它從隱藏字段的隱藏字段HF .The價值得到它,直到值是一個字符串10/22/2011。 ..但計時器顯示只剩下34分鐘,而它必須顯示2天和幾小時,剩下的一些分鐘..爲什麼?

回答

0

newYear串必須被轉換到一個Date對象:

var newYear = $(".HF").val(); 
newYear = new Date(newYear); // 10/22/2011 > Dat object of 22 Okt 2011