return FALSE; $r = well_tag_thread__update(array('id' => $id), $update); return $r; } function well_tag_thread_find($tagid, $page, $pagesize) { $arr = well_tag_thread__find(array('tagid' => $tagid), array('id' => -1), $page, $pagesize); return $arr; } function well_tag_thread_find_by_tid($tid, $page, $pagesize) { $arr = well_tag_thread__find(array('tid' => $tid), array(), $page, $pagesize); return $arr; } ?>javascript - .toLocaleDateString() Not Working in Firefox - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - .toLocaleDateString() Not Working in Firefox - Stack Overflow

programmeradmin2浏览0评论

I have the below code which prints out the date which is 10 working days from now. In Opera and Chrome it works as I expected and prints: Thursday, November 17, 2011

However in Firefox (6.0.2) it prints out: 11/17/2011

Does anyone know why the date isn't getting printed as a string in 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>

I have the below code which prints out the date which is 10 working days from now. In Opera and Chrome it works as I expected and prints: Thursday, November 17, 2011

However in Firefox (6.0.2) it prints out: 11/17/2011

Does anyone know why the date isn't getting printed as a string in 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>
Share Improve this question edited Feb 12, 2013 at 15:55 Cerbrus 73k19 gold badges136 silver badges150 bronze badges asked Nov 3, 2011 at 21:39 a1anma1anm 1,62911 gold badges45 silver badges79 bronze badges 2
  • Yeah perhaps you should specify if this is running in the same machine. As it seems the issue is with the system not the browser. – Griphox Commented Nov 4, 2011 at 1:16
  • Yes, I was on the same machine. However, I have since tried FF on a different machine and it worked as I had hoped. – a1anm Commented Nov 4, 2011 at 12:06
Add a ment  | 

1 Answer 1

Reset to default 4

According to the Mozilla documentation, the format can vary wildly depending on the user's location and puter settings.

https://developer.mozilla/en/JavaScript/Reference/Global_Objects/Date/toLocaleDateString

The exact format depends on the platform, locale and user's settings.

发布评论

评论列表(0)

  1. 暂无评论