相关文章:

JavaScript Date.setUTCMilliseconds() 函数详解

代码类型:

杂项:

  • 启用CSS/JS语法检查
  • 监测脚本运行错误
  • 禁止库文件重复

文档类型:

JS库文件:

手动添加:

     
    1
    xxxxxxxxxx
    21
     
    1
    //在当前页面内追加换行标签和指定的HTML内容
    2
    function w( html ){
    3
        document.body.innerHTML += "<br/>" + html;
    4
    }
    5
    6
    7
    8
    //当前运行环境的时区为 UTC +8
    9
    10
    //定义一个本地时间的Date对象"2012-03-15 13:11:43 123"
    11
    var date = new Date(2012, 2, 15, 13, 11, 43, 123);
    12
    w( date.toLocaleString() + " " + date.getMilliseconds() ); // 2012年3月15日 13:11:43 123
    13
    14
    date.setUTCMilliseconds(23);
    15
    w( date.toLocaleString() + " " + date.getMilliseconds() ); // 2012年3月15日 13:11:43 23
    16
    17
    date.setUTCMilliseconds(3600000);
    18
    w( date.toLocaleString() + " " + date.getMilliseconds() ); // 2012年3月15日 14:11:43 0
    19
    20
    date.setUTCMilliseconds(-1001);
    21
    w( date.toLocaleString() + " " + date.getMilliseconds() ); // 2012年3月15日 14:11:41 999
    xxxxxxxxxx
    1
     
    1