1. "2014-08-18 00:00:00" 与 13位毫秒 互换
1 var oTime = { 2 3 _format_13_time:function (str){ 4 var time = str.replace(new RegExp("-","gm"),"/"); 5 var haoMiao = (new Date(time)).getTime(); 6 return haoMiao; 7 }, 8 _add_zero: function (str) 9 { 10 if(parseInt(str) < 10){ 11 str = "0" + str; 12 } 13 return str; 14 }, 15 _format_date_time: function (str) 16 { 17 var d = new Date(); 18 d.setTime(str); 19 var YMDHMS = d.getFullYear() + "-" + oTimeObj._add_zero((d.getMonth()+1)) + "-" + oTimeObj._add_zero(d.getDate()) + " " 20 + oTimeObj._add_zero(d.getHours()) + ":" + oTimeObj._add_zero(d.getMinutes()) + ":" + oTimeObj._add_zero(d.getSeconds()); 21 return YMDHMS; 22 } 23 24 }
var msec = Date.parse("March 21, 2012"); //13位毫秒数
http://www.w3schools.com/js/js_date_methods.asp
来源:https://www.cnblogs.com/yiliweichinasoft/p/3929628.html