Mit diesem JavaScript lässt sich mittels Datumsfunktionen das Alter einer Seite bestimmen.
<!DOCTYPE html>
<html>
<head>
<title></title>
<script language="JavaScript">
<!--
today = new Date();
bYear = 1999; // Start Jahr
bMonth = 6; // Start Monat
bDay = 21; // Start Tag
tYear = today.getFullYear();
tMonth = (today.getMonth() ) + 1 ;
tDay = today.getDate();
tHour = today.getHours();
fYear = 0;
fMonth = 0;
fDay = 0;
fHour = 0;
x = 0;
y = 0;
z = 0;
a = 0;
b = 0;
c = 0;
function testMonth() {
if (y==4 || y==6 || y==9 || y==11) x=30
else if (y==2) x=28
else x=31
}
function testDay() {
fDay = (z - bDay) + tDay;
if (fDay > a) {
fMonth += 1;
fDay = fDay - a;
}
}
y = bMonth;
testMonth();
z = x;
y = bMonth;
testMonth();
a = x;
if (bMonth <= tMonth) {
fYear = tYear - bYear;
fMonth = (tMonth - bMonth);
testDay();
}
fYear = (tYear - bYear) - 1
fMonth = ((12 - bMonth) + tMonth) - 1;
testDay();
if (fMonth >= 12) {
fYear += 1;
fMonth -= 12;
}
with(Math) {
theYear=fYear;
tensYear=floor(theYear/10);
onesYear=theYear-(tensYear*1);
theMonth=fMonth
tensMonth=floor(theMonth/10);
onesMonth=theMonth-(tensMonth*1);
theDay=fDay
tensDay=floor(theDay/10);
onesDay=theDay-(tensDay*1);
var testArray = new makeArray("Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember");
for (z=1; z<=12; z++) {
if (tMonth==z) {
var b=testArray[z]
}
}
for (z=1; z<=12; z++) {
if (bMonth==z) {
var c=testArray[z]
}
}
}
var page
page = "Heutiges Datum: <b>"+tDay+". "+b+" "+tYear+".</b><br>"
page += "Diese Seite ist seit dem <b>"+bDay+". "+c+" "+bYear+"</b> im Netz<br>"
page += "Also genau <b>"
if(parseInt(tensYear+onesYear) == 1) {
page += tensYear + onesYear + " Jahr</b>,<b> "
}
else {
page += tensYear + onesYear + " Jahre</b>,<b> "
}
if(parseInt(tensYear+onesYear) == 0) {
page += ""
}
if(parseInt(tensMonth+onesMonth) == 1) {
page += tensMonth + onesMonth + " Monat </b>und<b> "
}
else {
page += tensMonth + onesMonth + " Monate </b>und<b> "
}
if(parseInt(tensDay+onesDay) == 1) {
page += tensDay + onesDay + " Tag</b>."
}
else {
page += tensDay + onesDay + " Tage</b>."
}
function makeArray() {
this.length = makeArray.arguments.length
for (var i = 0; i < this.length; i++)
this[i+1] = makeArray.arguments[i]
}
//-->
</script>
</head>
<body link="#5F0000" text="#6F6F6F" style="background-color:#FFFFFF"
>
<script language="JavaScript">
<!-- Hide this script from old browsers --
document.write(page)
// -- End Hiding Here -->
</script>
</body>
</html>