<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<script>
function DiffLong(datestr1, datestr2) {
var date1 = new Date(Date.parse(datestr1.replace(/-/g, "/")));
var date2 = new Date(Date.parse(datestr2.replace(/-/g, "/")));
var datetimeTemp;
var isLater = true;
if (date1.getTime() > date2.getTime()) {
isLater = false;
datetimeTemp = date1;
date1 = date2;
date2 = datetimeTemp;
}
difference = date2.getTime() - date1.getTime();
thisdays = Math.floor(difference / (1000 * 60 * 60 * 24));
difference = difference - thisdays * (1000 * 60 * 60 * 24);
thishours = Math.floor(difference / (1000 * 60 * 60));
difference = difference - thishours * (1000 * 60 * 60);
thismin = Math.floor(difference / (1000 * 60));
var strRet = thisdays + '天' + thishours + '小时'+thismin+'分';
return strRet;
}
function test(){
alert( DiffLong("2014-09-14 12:23:19","2014-09-15 13:24:19"));
}
</script>
</head>
<body>
<input type="button" value="按我" onClick="test()"/>
</body>
</html>