The JavaScript web page implements a countdown program to calculate the time remaining in the current year, and the javascript countdown
I saw an error in this program on the Internet and corrected it here:
Function counter () {var date = new Date (); var year = date. getFullYear (); var date2 = new Date (year, 11, 30, 23, 59, 59);/* convert to seconds */var time = (date2-date) /1000; var day = Math. floor (time/(24*60*60) var hour = Math. floor (time % (24*60*60)/(60*60) var minute = Math. floor (time % (24*60*60) % (60*60)/60); var second = Math. floor (time % (24*60*60) % (60*60) % 60 ); var str = year + "years remaining" + day + "day" + hour + "hour" + minute + "minute" + second + "second"; console. log (str);} window. setInterval ("counter ()", 1000 );
I wrote this myself.
Var oDateNow = new Date (); var oYear = oDateNow. getFullYear (); var oDateEnd = new Date (); oDateEnd. setFullYear (oYear + 1); oDateEnd. setMonth (0); oDateEnd. setDate (0); oDateEnd. setHours (0); oDateEnd. setMinutes (0); oDateEnd. setSeconds (0); function upDate () {var oDateNow = new Date (); var iTime = oDateEnd. getTime ()-oDateNow. getTime (); var iRemain = iTime/1000; var iDay = parseInt (iRemain/86400); iRemain % = 86400; var iHour = parseInt (iRemain/3600 ); iRemain % = 3600; var iMin = parseInt (iRemain/60); iRemain % = 60; var iSec = parseInt (iRemain); document. write (oYear + "years left" + iDay + "day" + iHour + "Hour" + iMin + "Minute" + iSec + "second ");} setInterval (function () {upDate ()}, 1000 );
The seconds of these two methods are sourced
The above section describes how to implement a countdown program to calculate the time remaining in the current year on the JavaScript web page. I hope it will help you. If you have any questions, please leave a message, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!