<!DOCTYPE HTML>
<html lang="en-us">
<head>
<meta charset="utf-8"/>
<title>JS计算时间差</title>
<meta name="generator" content="kingwell"/>
<meta name="author" content="kingwell"/>
<meta name="keywords" content="kingwell"/>
<meta name="description" content="kingwell"/>
<style type="text/css"></style>
<script type="text/javascript">
var t1 = new Date(2013,1,20,12,40,0);
var t2 = new Date(2013,3,20,14,40,0);
var t3 = t2.getTime() - t1.getTime();
var y = Math.floor( t3 / (1000*3600*24*365));
var d = Math.floor( t3 / (1000*3600*24));
var h = Math.floor( t3 / (1000*3600));
var m = Math.floor( t3 / (1000*60));
alert("离现在已经有:" +y+" 年 \n离现在已经有:"+d+ " 天\n离现在已经有:"+h+ " 小时\n离现在已经有:" +m + " 分\n");
</script>
</head>
<body>
</body>
</html>