<html>
<body>
<script>
function tab(date){
var oDate = new Date();
var nY = oDate.getFullYear();
var nM = oDate.getMonth();
var nD = oDate.getDate();
var newDate = new Date(nY,nM,nD,0,0,0);
var date = date.split('-');
var lastDate = new Date(date[0],(date[1]-1),date[2],0,0,0);
var result = '';
if(newDate.getTime() > lastDate.getTime()){
result = date[0]+'年'+date[1]+'月'+date[2]+'日到今天已经过去了('+ (newDate.getTime()-lastDate.getTime())/86400000 +')天了';
}else{
result = date[0]+'年'+date[1]+'月'+date[2]+'日到今天还有('+ Math.abs(newDate.getTime()-lastDate.getTime())/86400000 +')天了';
}
return result;
}
console.log(tab('2016-07-01'));
</script>
<font color=#f00 >
<script>
document.write(tab('2016-07-01'));
</script>
</font>
</body>
</html>
星期一, 12/26/2016 - 23:27 — 杨超