Js detection method for determining how many days the date is later than _ javascript tips-js tutorial

Source: Internet
Author: User
This article mainly introduces how to determine the number of days for js detection and involves related techniques of javascript operation date, which has some reference value, for more information about how to use JavaScript to detect the number of days with a date, see the example in this article. Share it with you for your reference. The specific analysis is as follows:

This example shows how to use js to compare the local time (the time on the visitor's computer, or the Standard Time) based on the date in the tag span, for example, the difference of 15 days:

  How to Use js detection to determine the number of days with a date greaterScript window. onload = function () {var ul1 = document. getElementById ("time"); var span1 = ul1.getElementsByTagName ("span"); var data = span1 [0]. innerHTML; var a = data. split (""); var B = a [0]. split ("-"); var c = a [1]. split (":"); var oldTime = new Date (B [0], B [1]-1, B [2], c [0], c [1], c [2]); var nowTime = new Date (); document. write (nowTime-oldTime)/(1000*60*60*24)> 15? "Greater than 15": "less than 15");} script

  • 08:52:32

I hope this article will help you design javascript programs.

Related Article

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.