Traditional Culture Encyclopedia - Almanac inquiry - How to display the current time (seconds and minutes) in js?
How to display the current time (seconds and minutes) in js?
Function show(){
var Date = new Date(); //Date object
var now =““;
now = date . getfullyear()+“year“; //Only read English.
Now = now+(date. getmonth()+ 1)+“month“; //Take the current month when taking the month-1. If you want to take the current month+1, you can do this.
now = now+date . getdate()+“day”;
now = now+date . get hours()+“when“;
Now = now+date. get minutes()+ "integral";
Now = now+date. get seconds()+ "seconds";
document . getelementbyid(“now div“)。 The html of innerHTML = now// now //div is a string.
setTimeout(“show()“, 1000); //Set 1000 ms to 1 sec and call the show method.
}
& lt/script & gt;
& ltbody onload =“show()“& gt; & lt! -Called once when the webpage is loaded, and then automatically called->
& ltdiv id =“now div“& gt; & lt/div & gt;
& lt/body & gt;
You can see the effect by copying directly.
- Related articles
- Qing Palace Chart 202 1 Table of Boys and Girls
- China perpetual calendar official website.
- Who killed this town four years ago?
- Old almanac randomly generates calendars.
- Dream of being touched by porcelain
- Xiaohuangli
- Will the early winter of 2020 be a good time to move?
- Huangli wine
- Dream of quarreling and throwing plates
- Pregnant men and women in the yellow calendar