我需要一个显示当前时间(12小时)的html代码,几秒钟后显示当天的名称(星期六,星期日),几秒钟后显示日期,然后显示时间等循环。有人能帮帮我吗?提前感谢
您需要编写一些Javascript来实际为您做:
let dt = new Date;
console.log(dt)
您也可以使用Date
的方法:
let dt = new Date;
console.log("Year: ", dt.getFullYear())
console.log("Month: ", dt.getMonth())
// Or to get the name of the month:
const monthNames = ["January", "February", "March", "April", "May", "June","July", "August", "September", "October", "November", "December"];
console.log("Month name: ", monthNames[dt.getMonth()])
//Thanks to https://stackoverflow.com/users/135589/jesper!
console.log("Day: ", dt.getDay()) //Returns day of the week!
//etc...
更多参考:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date