初学者两个基础问题
1。怎么计算两个时间之间的差值。 比如 现在到明天12点还差多少时间
2。body中有一个表单 在表单外面有一个button 我想实现点了这个button后 就在表单里 加一个text 这怎么实现?
分是有点少了 不过我也就这么一点分了 谢谢大家的回答!
------解决方案--------------------dt1 = new Date();
y = dt1.getFullYear();
<script>
m = dt1.getMonth();
d = dt1.getDate();
dt2 = new Date(y,m,d+1,12);
diff = (dt2.getTime() - dt1.getTime())/(60*60*1000);
diff = Math.round(diff*100)/100;
alert( "还差 " + diff + "小时 ");
diff = (dt2.getTime() - dt1.getTime())/(60*1000);
diff = Math.round(diff*100)/100;
alert( "还差 " + diff + "分钟 ");
</script>