Home > Article > Web Front-end > Detailed explanation and examples of Javascript implementation of calculator time function (2)
Javascript Calculator:
Series of articles:
JS Detailed explanation and example code for implementing calculator (1)
Javascript Detailed explanation and example for implementing calculator time function (2) )
Javascript Calculator-> Add time Add time display in the upper left corner of the screen display area
The effect is as follows:
Code
Initialize Javascript calculator
// 计算器初始化 Calculator.prototype.init = function () { this.addTdClick(); // 时间显示 this.showDate(); };
Time display
// 在屏显区左上角显示时间日期 Calculator.prototype.showDate = function () { $("result-date").innerText = new Date().format("hh:mm:ss EEE yyyy-MM-dd"); var that = this; if (this.timer) clearTimeout(this.timer); this.timer = setTimeout(function(){ that.showDate(); }, 1000); };
Time formatting
Date.prototype.format = function (dateStr){}
Get the time every second through the timer to display
Thanks for reading, I hope it can help everyone, thank you for your support of this site!
For more Javascript implementation details and examples of calculator time function (2), please pay attention to the PHP Chinese website for related articles!