English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
This article shares the specific implementation code of the Date Calculator for your reference, the specific content is as follows
Date Calculator html code snippet:
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Date Calculator</title> <script type="text/javascript" src="date_calc.js"></script> </head> <body> <br><br> <b>Calculate the date after several days:</b>/b> <br> and <input size="8" id="SY" value="2016">year <input size="4" id="SM" value="11">month <input size="4" id="SD" value="16">Sun (Default is today) <br>Difference <input size="8" id="decday" value="100">days (Input a negative number to calculate backward) <br>Is: <span id="result1></span> <br> <input type=button value="Calculate" onclick="cala()"> <br> <b>Calculate date difference:</b>/b> <br> <input size="8" id="SY2" value="2016">year <input size="4" id="SM2" value="11">month <input size="4" id="SD2" value="16">Sun <br> and <input size="8" id="SY3" value="2017" >year <input size="4" id="SM3" value="1">month <input size="4" id="SD3" value="1">Sun <br>Difference: <span id="result2></span>days <br> <input type=button value="Calculate" onclick="calb()"> <br> </body> </html>
date_calc.js code snippet:
var hzWeek = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"); //Get the week day function cweekday(wday) {return hzWeek[wday];} function cala() { y = document.getElementById("SY").value; m = document.getElementById("SM").value; d=document.getElementById("SD").value; ddd=document.getElementById("decday").value; ttt=new Date(y,m-1,d).getTime()+ddd*24000*3600; theday=new Date(); theday.setTime(ttt); document.getElementById("result1").innerHTML=theday.getFullYear()+"Year"+(1+theday.getMonth())+"Month"+theday.getDate()+"Day"+"Weekday"+cweekday(theday.getDay()); } function calb() { y2=document.getElementById("SY2").value; m2=document.getElementById("SM2").value; d2=document.getElementById("SD2").value; y3=document.getElementById("SY3").value; m3=document.getElementById("SM3").value; d3=document.getElementById("SD3").value; day2=new Date(y2,m2-1,d2); day3=new Date(y3,m3-1,d3); document.getElementById("result2").innerHTML=(day3-day2)/86400000; }
That's all for this article. I hope it will be helpful to everyone's learning and that everyone will support the Yelling Tutorial more.
Statement: The content of this article is from the Internet, and the copyright belongs to the original author. The content is contributed and uploaded by Internet users spontaneously. This website does not own the copyright, has not been manually edited, and does not assume relevant legal liability. If you find any content suspected of copyright infringement, please send an email to: notice#oldtoolbag.com (When sending an email, please replace # with @ to report abuse, and provide relevant evidence. Once verified, this site will immediately delete the infringing content.)