Vise dato med JavaScript

Dette JavaScriptet skriver ut dato på en side.

  1. <<script language="javascript" type="text/javascript">
  2. today = new Date();
  3. weekday = today.getDay();
  4. document.write(' ');
  5. if (weekday == 0) document.write('Søndag');
  6. if (weekday == 1) document.write('Mandag');
  7. if (weekday == 2) document.write('Tirsdag');
  8. if (weekday == 3) document.write('Onsdag');
  9. if (weekday == 4) document.write('Torsdag');
  10. if (weekday == 5) document.write('Fredag');
  11. if (weekday == 6) document.write('Lørdag');
  12. if (weekday == 7) document.write('Søndag');
  13. date = today.getDate();
  14. document.write(' ' + date+ '. ');
  15. month = today.getMonth();
  16.  
  17. if (month == 0) document.write('Januar');
  18. if (month == 1) document.write('Februar');
  19. if (month == 2) document.write('Mars');
  20. if (month == 3) document.write('April');
  21. if (month == 4) document.write('Mai');
  22. if (month == 5) document.write('Juni');
  23. if (month == 6) document.write('Juli');
  24. if (month == 7) document.write('August');
  25. if (month == 8) document.write('September');
  26. if (month == 9) document.write('Oktober');
  27. if (month == 10) document.write('November');
  28. if (month == 11) document.write('Desember');
  29.  
  30. year=today.getYear();
  31. document.write (' ' +year);
  32. document.write (' ');
  33.  
  34. </script>

Jeg har hatt noen problemer med å vise riktig dato i Netscape, ironisk nok. Ser du hvorfor, kan du kontakte meg!

Copyright 1995 - 2008 Martin Bekkelund
xhtml
css
rss
cc
508
aaa
v6.08b