Vise dato med JavaScript
Dette JavaScriptet skriver ut dato på en side.
- <<script language="javascript" type="text/javascript">
- today = new Date();
- weekday = today.getDay();
- document.write(' ');
- if (weekday == 0) document.write('Søndag');
- if (weekday == 1) document.write('Mandag');
- if (weekday == 2) document.write('Tirsdag');
- if (weekday == 3) document.write('Onsdag');
- if (weekday == 4) document.write('Torsdag');
- if (weekday == 5) document.write('Fredag');
- if (weekday == 6) document.write('Lørdag');
- if (weekday == 7) document.write('Søndag');
- date = today.getDate();
- document.write(' ' + date+ '. ');
- month = today.getMonth();
-
- if (month == 0) document.write('Januar');
- if (month == 1) document.write('Februar');
- if (month == 2) document.write('Mars');
- if (month == 3) document.write('April');
- if (month == 4) document.write('Mai');
- if (month == 5) document.write('Juni');
- if (month == 6) document.write('Juli');
- if (month == 7) document.write('August');
- if (month == 8) document.write('September');
- if (month == 9) document.write('Oktober');
- if (month == 10) document.write('November');
- if (month == 11) document.write('Desember');
-
- year=today.getYear();
- document.write (' ' +year);
- document.write (' ');
-
- </script>
Jeg har hatt noen problemer med å vise riktig dato i Netscape, ironisk nok. Ser du hvorfor, kan du kontakte meg!