[JavaScript] a dynamic clock synchronized to the local time and custom time format, javascript time format

Source: Internet
Author: User

[JavaScript] a dynamic clock synchronized to the local time and custom time format, javascript time format

This article improves [JavaScript] The Dynamic Time synchronized to local time (click to open the link ).

In addition to toLocaleString (), the Date type in JavaScript can be converted into a system-formatted time.

You can also customize the time format. For example, you can construct a dynamic clock that is similar to the QQ chat box and synchronized to the local time.


The Code is as follows:

<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> The idea is exactly the same as [JavaScript] A Dynamic Time synchronized to the local time. The key is the setInterval function. At the same time, the reason why we need to add a condition structure of less than 10 is that, if we do not add it, for example, 19:01:01 will become, which is not in line with our habits.

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.