今天是今年的第几天
<script>
var date123 = new Date();
var datemonth = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
var year= date123.getFullYear()//获取年份
var month= date123.getMonth()//获取月份
var day= date123.getDate()//获取天
var sum = 0;
for( i = 0 ; i <month; i++){
sum+=datemonth[i];
}sum += day;
document.write("今天是"+year+"年"+(month+1)+"月"+day+"日,是今年的第"+sum +"天");
</script>
动态时钟
<script>
function date(){
var date123 = new Date();
var year= date123.getFullYear()//获取年份
var month= date123.getMonth()//获取月份
var day= date123.getDate()//获取天
var hours= date123.getHours()//获取小时
var minutes= date123.getMinutes()//获取分钟
var seconds= date123.getSeconds()//获取秒;
document.getElementById("time").innerHTML=year+"年"+month+1+"月"+day+"日"+hours+"时"+minutes+"分"+seconds+"秒";
}
date();
setInterval( date,1000)
</script>