Full version: jsB@nk » Time » Counter » Days Since
URL: https://www.javascriptbank.com/days-since.html
This JavaScript displays the number of years, months, and days since a selected event. The output can easily be formatted using CSS.
Full version: jsB@nk » Time » Counter » Days Since
URL: https://www.javascriptbank.com/days-since.html
<script language="javascript">// Created by: Chris Hallberg :: http://kanoa.heavenfromhell.comfunction time() { // Enter the month, day, and year below you want to use as // the starting point for the date calculation var amonth = 9 var aday = 11 var ayear = 2001 var x = new Date() var dyear var dmonth var dday var tyear = x.getFullYear() var tmonth = x.getMonth()+1 var tday = x.getDate() var y=1 var mm=1 var d=1 var a2=0 var a1=0 var f=28 if ((tyear/4)-parseInt(tyear/4)==0) { f=29 } m = new Array(31, f, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31) dyear = tyear-(ayear) dmonth = tmonth-amonth if (dmonth<0) { dmonth = dmonth+12 dyear-- } dday = tday-aday if (dday<0) { var ma = amonth+tmonth if (ma>12) {ma = ma-12} if (ma=0) {ma = ma+12} dday = dday+m[ma] dmonth-- } if (dyear==0) {y=0} if (dmonth==0) {mm=0} if (dday==0) {d=0} if ((y==1) && (mm==1)) {a1=1} if ((y==1) && (d==1)) {a1=1} if ((mm==1) && (d==1)) {a2=1} if (y==1){ document.write(+dyear+" Years") } if ((a1==1) && (a2==0)) {document.write(" and ")} if ((a1==1) && (a2==1)) {document.write(", ")} if (mm==1){ document.write(dmonth+" Months") } if (a2==1) {document.write(", and ")} if (d==1){ document.write(+dday+" Days") }}</script><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->
<b><script type="text/javascript">time()</script></b> since September 11, 2001<!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->