JS时间的不同写法

 <script type="text/javascript">
        var thedate = new Date(2012, 3, 7, 12, 11, 12,222);
        alert(thedate.toLocaleString());//时间将变成本地的字符串表示
        alert(thedate.getMilliseconds());//获取毫秒

      
      
        var thedate = new Date('2012, March, 7,12:11:22');
        alert(thedate.toLocaleString()); //时间将变成本地的字符串表示
        alert(thedate.getMilliseconds());//获取毫秒(没有值为0)
      alert(thedate.getYear()); //建议使用GetFullYear获取年,获取年                
    </script>

原文地址:https://www.cnblogs.com/duanlinlin/p/3010839.html