site afteller scrip bewerken.

Status
Niet open voor verdere reacties.

JP_Linkens

Gebruiker
Lid geworden
15 mrt 2006
Berichten
64
Heey, deze teller telt af dus laat zien hoeveel dagen de site al bestaat, kan iemand me hem aanpassen zodat hij laat zien hoeveel dagen weken maanden en jaren oud hij is.


alvast bedankt.

HTML:
<SCRIPT LANGUAGE="JavaScript">
// Script featured on Able2Know.com
// Find free scripts & get free help: http://search.able2know.com/web_development/scripts/

<!-- Begin
var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
function countup(yr,m,d) {
var today=new Date();
var todayy=today.getYear();

// Y2K Fix by Isaac Powell
// http://onyx.idbsu.edu/~ipowell

if ((navigator.appName == "Microsoft Internet Explorer") && (todayy < 2000))		
todayy="19" + todayy;
if (navigator.appName == "Netscape")
todayy=1900 + todayy;

var todaym=today.getMonth();
var todayd=today.getDate();
var todaystring=montharray[todaym]+" "+todayd+", "+todayy;
var paststring=montharray[m-1]+" "+d+", "+yr;
var difference=(Math.round((Date.parse(todaystring)-Date.parse(paststring))/(24*60*60*1000))*1);

document.write("JSS was created " + difference + " days ago.");

}
countup(1997,08,29);  // Date in format:  (year,month,day)
//  End -->
</script>
 
Die laatste
countup(1997,08,29); // Date in format: (year,month,day)

Veranderen in bijv.
countup(2006, 03, 21);
 
dropl zei:
Die laatste
countup(1997,08,29); // Date in format: (year,month,day)

Veranderen in bijv.
countup(2006, 03, 21);

Uhhm nee dat is zodat hij vanaf vandaag gaat tellen, dat snap ik.
Maar hij geeft weer in dagen en hij moet weergeven in jaar maand en dagen.

Hij doet nu This site is online for 3126 days. (Jah volgens scripje dat hier stata iets van JSS maard at had ik al evrnadert) en als ik dat evrander wat jij zeg geeft hier hier nu 0 aan, dat en moet ik ook nog verandere maard as geen probleem, alleen ik moet aangeven BV 1 jaar 2 maanden en 4 dagen.

Groet,
JP
 
Ik heb het script voor het grootste stuk herschreven, en het volgende werkt, maar nog niet in firefox :

HTML:
<script language="javascript">
<!--
var days_arr = new Array(31,"",31,30,31,30,31,31,30,31,30,31);
var next_leapyear = 2000;
function countup(yr,m,d) {
var today = new Date();
var todayy = today.getYear();
var todaym = today.getMonth();
var todayd = today.getDate();
for (var i = yr; i < todayy; i++) {
if (i == next_leapyear) {
days_arr[1] = 29;
next_leapyear += 4;
} else {
days_arr[1] = 28;
};
};
var yearDiff = todayy - yr;
var monthDiff = todaym - (m - 1);
var dayDiff = todayd - d;
if (dayDiff < 0) {
monthDiff -= 1;
yearDiff -= 1;
dayDiff += days_arr[m-2];
};
monthDiff += (monthDiff < 0) ? 12 : 0;
yearDiff -= ((monthDiff < 12) && (dayDiff < 0)) ? 1 : 0;
var yearS = (yearDiff != 1) ? "years" : "year";
var monthS = (monthDiff != 1) ? "months" : "month";
var dayS = (dayDiff != 1) ? "days" : "day";
if ((navigator.appName == "Microsoft Internet Explorer") && (todayy < 2000)) todayy = "19" + todayy;
if ((navigator.appName == "Netscape Navigator") && (todayy < 2000)) todayy = 1900 + todayy;
document.write("<center>JSS was created " + yearDiff + " " + yearS + ", " + monthDiff + " " + monthS + " and " + dayDiff + " " + dayS + " ago.</center>");
};
countup(2005,03,22);
-->
</script>
De telling klopt ook in een schrikkeljaar.
Voorbeeld

Greetz :Jer:cool:en.
 

Bijlagen

Laatst bewerkt:
Er blijkt toch nog een foutje in te zitten. :o :(

Greetz : Jer:cool:en.
 
:)

JeroenE zei:
Er blijkt toch nog een foutje in te zitten. :o :(

Greetz : Jer:cool:en.


Nou ik kan het zelf niet zonder fout maken ( Denk daar maar eens over naar;) )
Dus is niet erg, ik merk wel als je hebt gepost dat foutje eruit is dan duw ik hem meteen in de site:)

Alvast bedankt.

Groet,
JP
 
JeroenE zei:
... het volgende werkt, maar nog niet in firefox:
var todayy = today.getFullYear();

Dat werkt hetzelfde bij Ie en Fx. :) Voor vandaag geven ze dan beide: 2006.

Vr.Gr. Egel.
 
Ok wat is dan uiteindelijk het totale werkende werkende scripje? (Kan dat gepost worden?)

Thnx

Groet,
JP
 
Dank je wel, Egel voor de tip. :thumb:
Het werkt nu inderdaad ook in Firefox. ;)
En het foutje is er ondertussen ook uit. :)
Hier is het script :

HTML:
<script language="javascript">
<!--
var month_arr = new Array("Januari","Febuari","March","April","Mai","June","July","August","September","October","November","December");
var days_arr = new Array(31,"",31,30,31,30,31,31,30,31,30,31);
var next_leapyear = 2000;
function countup(yr,m,d) {
var today = new Date();
var todayy = today.getFullYear();
var todaym = today.getMonth();
var todayd = today.getDate();
days_arr[1] = (todayy == next_leapyear) ? 29 : 28;
var yearDiff = todayy - yr;
var monthDiff = todaym - (m - 1);
var dayDiff = todayd - d;
if (dayDiff < 0) {
monthDiff -= 1;
if (yearDiff > 0) {
yearDiff -= 1;
};
dayDiff += days_arr[m-1];
};
monthDiff += (monthDiff < 0) ? 12 : 0;
yearDiff -= ((monthDiff < 0) && (dayDiff < 0)) ? 1 : 0;
var yearS = (yearDiff != 1) ? "years" : "year";
var monthS = (monthDiff != 1) ? "months" : "month";
var dayS = (dayDiff != 1) ? "days" : "day";
if ((navigator.appName == "Microsoft Internet Explorer") && (todayy < 2000)) todayy = "19" + todayy;
if ((navigator.appName == "Netscape Navigator") && (todayy < 2000)) todayy = 1900 + todayy;
document.write("<center><p>JSS was created on " + d + " " + month_arr[m-1] + " " + yr + "</p>");
document.write("JSS was created " + yearDiff + " " + yearS + ", " + monthDiff + " " + monthS + " and " + dayDiff + " " + dayS + " ago.</center>");
};
countup(1999,03,23);
-->
</script>
Nog even een -> voorbeeld <-.
Veel plezier.

Greetz : Jer:cool:en.
 

Bijlagen

Laatst bewerkt:
Klein foutje

Heey ik zag dat er nog een klein foutje was dus heb ik dat maar verbetert. (De maanden waren half engels half nederlands)

Hier de goede, Eerst Nederlands daarna engels.


Nederlands
PHP:
<script language="javascript">
<!--
var month_arr = new Array("Januari","Februari","Maart","April","Mei","Juni","Juli","Augustus","September","Oktober","November","December");
var days_arr = new Array(31,"",31,30,31,30,31,31,30,31,30,31);
var next_leapyear = 2000;
function countup(yr,m,d) {
var today = new Date();
var todayy = today.getFullYear();
var todaym = today.getMonth();
var todayd = today.getDate();
days_arr[1] = (todayy == next_leapyear) ? 29 : 28;
var yearDiff = todayy - yr;
var monthDiff = todaym - (m - 1);
var dayDiff = todayd - d;
if (dayDiff < 0) {
monthDiff -= 1;
if (yearDiff > 0) {
yearDiff -= 1;
};
dayDiff += days_arr[m-1];
};
monthDiff += (monthDiff < 0) ? 12 : 0;
yearDiff -= ((monthDiff < 0) && (dayDiff < 0)) ? 1 : 0;
var yearS = (yearDiff != 1) ? "years" : "year";
var monthS = (monthDiff != 1) ? "months" : "month";
var dayS = (dayDiff != 1) ? "days" : "day";
if ((navigator.appName == "Microsoft Internet Explorer") && (todayy < 2000)) todayy = "19" + todayy;
if ((navigator.appName == "Netscape Navigator") && (todayy < 2000)) todayy = 1900 + todayy;
document.write("<center><p>JSS was created on " + d + " " + month_arr[m-1] + " " + yr + "</p>");
document.write("JSS was created " + yearDiff + " " + yearS + ", " + monthDiff + " " + monthS + " and " + dayDiff + " " + dayS + " ago.</center>");
};
countup(1999,03,23);
-->
</script>

En nu de Engelstalige

PHP:
<!--
<script language="javascript"> 
var month_arr = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
var days_arr = new Array(31,"",31,30,31,30,31,31,30,31,30,31);
var next_leapyear = 2000;
function countup(yr,m,d) {
var today = new Date();
var todayy = today.getFullYear();
var todaym = today.getMonth();
var todayd = today.getDate();
days_arr[1] = (todayy == next_leapyear) ? 29 : 28;
var yearDiff = todayy - yr;
var monthDiff = todaym - (m - 1);
var dayDiff = todayd - d;
if (dayDiff < 0) {
monthDiff -= 1;
if (yearDiff > 0) {
yearDiff -= 1;
};
dayDiff += days_arr[m-1];
};
monthDiff += (monthDiff < 0) ? 12 : 0;
yearDiff -= ((monthDiff < 0) && (dayDiff < 0)) ? 1 : 0;
var yearS = (yearDiff != 1) ? "years" : "year";
var monthS = (monthDiff != 1) ? "months" : "month";
var dayS = (dayDiff != 1) ? "days" : "day";
if ((navigator.appName == "Microsoft Internet Explorer") && (todayy < 2000)) todayy = "19" + todayy;
if ((navigator.appName == "Netscape Navigator") && (todayy < 2000)) todayy = 1900 + todayy;
document.write("<center><p>JSS was created on " + d + " " + month_arr[m-1] + " " + yr + "</p>");
document.write("JSS was created " + yearDiff + " " + yearS + ", " + monthDiff + " " + monthS + " and " + dayDiff + " " + dayS + " ago.</center>");
};
countup(1999,03,23);
-->
</script>

Nu is hij helemaal goed:)
 
Laatst bewerkt:
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan