Detailed description and example of the time function of the calculator implemented by Javascript (2)

Source: Internet
Author: User
Tags add time
This article describes how to implement the time function of the calculator in Javascript and the related information of the instance. If you need it, refer to the following Javascript calculator:

Series of articles:

JS implementation calculator details and instance code (1)

Detailed description and example of the time function of the calculator implemented by Javascript (2)

Javascript calculator-> add time to add time display in the upper left corner of the screen display area

As follows:

Code

Initialize Javascript Calculator

// Calculator initializes Calculator. prototype. init = function () {this. addTdClick (); // time display this. showDate ();};

Time Display

// Display the time and date Calculator in the upper left corner of the screen display area. 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 Format

Date. prototype. format = function (dateStr ){}

Obtain the display time by using the timer every second

Thank you for reading this article. I hope it will help you. Thank you for your support for this site!

For more details about how to implement the calculator time function in Javascript and related articles (2), please follow the PHP Chinese network!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.