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
I hope this article will help you design javascript programs.