"0"+date.getSeconds() : date.getSeconds()this.datetime = hour +':'+ minute +':'+secound//获取日期:年月日constyear =date.getFullYear()constmonth = date.getMonth() +1constday =date.getDate()this.nowDate = month +"月"+ day +"日"this.nowYear = year +"年"//获取星期几constweeks...
你可以简单地创建一个新的Date对象来获取当前时间。 javascript const now = new Date(); 从Date对象中提取年份、月份和日期: 使用getFullYear()、getMonth()和getDate()方法可以从Date对象中提取年份、月份和日期。注意,getMonth()方法返回的月份是从0开始的(即0代表1月,11代表12月),因此你需要对其进行适当...
document.getElementById('clock').innerHTML = (today.getFullYear() +'年'+ (today.getMonth() +1) +'月'+ today.getDate() +'日'+ hou +':'+today.getMinutes() +':'+today.getSeconds() +''+time+'星期'+day); }varmyTime = setInterval('time()',1000); console.log(myTime);...
显示结果格式:2013年07月06日 星期六 农历癸巳年 五月廿八 明日小暑 调用格式: //获取当前时间 var nowDateInfo = getNowDate(); //$("#nowDateInfo").html(nowDateInfo); document.getElementById("nowDateInfo").innerHTML = nowDateInfo; 2, JS代码如下: function getNowDate(){ var today=new Dat...