Dieser Artikel beschreibt die Methode von JavaScript, um zu vergleichen, ob die aktuelle Zeit innerhalb eines bestimmten Zeitraums liegt. Teilen Sie es für Ihre Referenz wie folgt weiter:
Funktionsprüfung (Stime, etime) {// Startzeit var arrrs = stime.split ("-"); var startTime = neues Datum (arrs [0], arrrs [1], arrrs [2]); var startTimes = startTime.getTime (); // Endzeit var arr = etime.split ("-"); var endime = neues Datum (arre [0], arr [1], arr [2]); var endTimes = endTime.getTime (); // aktuelle Zeit var thate = new Date (); var thatates = thatate.getingfullyear () + "-0" + (thisdate.getMonth () + 1) + "-" + thate.getDate (); var arrn = thates.Split ("-"); var NowTime = neues Datum (arrn [0], arrn [1], arrn [2]); var nowtimes = nuntime.getTime (); if (nowtimes <starttimes || nowtimes> endtimes) {return false; } return true;} // Verwendung: var timebool = checkTime ('2016-8-1', '2016-8-10'); // Hinweis: Die Daten werden durch "-" if (timebool == true) {document.write ('Das aktuelle Datum des angegebenen Zeitraums'); {{document.write ('Das aktuelle Datum ist nicht innerhalb des aktuellen Zeitraums';PS: Freunde, die an JavaScript -Zeit- und Datumsangeboten interessiert sind, können sich auch auf die Online -Tools dieser Website beziehen:
Unix Timestamp Conversion Tool:
http://tools.vevb.com/code/unixtime
Online -Zeitanfrage auf der ganzen Welt:
http://tools.vevb.com/zhuanhuanqi/worldtime
Online -Perpetual -Kalender:
http://tools.vevb.com/bianmin/wannianli
Web -Perpetual -Kalender:
http://tools.vevb.com/bianmin/webwannianli
For more information about JavaScript, please check this site's special topics: "Summary of JavaScript Time and Date Operation Skills", "Summary of JavaScript Switching Effects and Skills", "Summary of JavaScript Search Algorithm Skills", "Summary of JavaScript Animation Special Effects and Skills", "Summary of JavaScript Errors and Debugging Skills", "Summary of JavaScript Data Structures and Algorithm Skills", "Zusammenfassung des JavaScript -Traversalalgorithmus und der Fähigkeiten" und "Zusammenfassung der Verwendung von JavaScript Mathematical Operation Nutzung"
Ich hoffe, dieser Artikel wird für JavaScript -Programme aller hilfreich sein.