<script language="JavaScript">
<!--
str="12/22/2003 11:52:23:101"
t1=/(.+):(\d{3})$/.exec(str)var d=Date.parse(t1[1]);alert(new Date(d));
alert(new Date(t1[2]-0+d));</script>
不过好像没什么含义
<!--
str="12/22/2003 11:52:23:101"
t1=/(.+):(\d{3})$/.exec(str)var d=Date.parse(t1[1]);alert(new Date(d));
alert(new Date(t1[2]-0+d));</script>
不过好像没什么含义
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>今天巨烦,到论坛里遛遛</title>
</head><body></body>
</html>
<script>
var dateStr="12/22/2003 11:52:23:101";
var tempDate0=new Date((dateStr.substr(0,19)));//得到精确到秒的日期
var tempDate1=new Date(tempDate0*1+dateStr.substr(20,3)*1);//得到精确到毫秒的日期
alert(tempDate0*1);
alert(tempDate1*1);//可以看到转换后的日期是否正确</script>
我试了一下,好象时间还是没有毫秒的啊.
用getMilliseconds()还是0的.
var dateStr="12/22/2003 11:52:23:101";
var tempDate=new Date((dateStr.substr(0,19)));//得到精确到秒的日期
tempDate.setMilliseconds(dateStr.substr(20,3)*1);
alert(tempDate.getMilliseconds());</script>注:
new Date(dateStr);
相当于: new Date(Date.parse(dateStr));
查了一下parse的说明,它只能精确到秒.
如果要精确到毫秒
得自个去setMilliseconds(millisecondNum);
或者说用: new Date(millisecondNum);
或者用: new Date(year, month, date[, hours[, minutes[, seconds[,ms]]]])