2011-11-03 140 views
5

我有下面的代碼打印出10個工作日後的日期。在Opera和Chrome它的作品如我所料,並打印: 週四,2011年11月17日在Firefox.toLocaleDateString()在Firefox中不工作

但是(6.0.2),它打印出:11/17/2011

有誰知道爲什麼日期沒有被打印爲Firefox中的字符串?

<script type="text/javascript"> 
    function businessDays(n){ 
     var D=new Date(); 
     var num=Math.abs(n); 
     var tem,count=0; 
     var dir= (n<0)? -1: 1; 
     while(count< num){ 
      D= new Date(D.setDate(D.getDate()+dir)); 
      tem=D.getDay(); 
      if(tem!=0 && tem!=6) ++count; 
     } 
     return D; 
    } 
    var D=businessDays(10).toLocaleDateString(); //string 
    document.write(D); 
</script> 
+0

是的,也許你應該指定,如果這是在同一臺機器上運行。因爲看起來問題在於系統而不是瀏覽器。 – Griphox

+0

是的,我在同一臺機器上。不過,我從另一臺機器上嘗試過FF,並且按照我的希望工作。 – a1anm

回答