Prosty skrypt java wyświetlający bieżącą datę:
w sekcji <head> wpisz
<script language="JavaScript">
<!--
function MakeArray(n) {
this.length = n
return this
}
monthNames = new MakeArray(12)
monthNames[1] = "stycznia"
monthNames[2] = "lutego"
monthNames[3] = "marca"
monthNames[4] = "kwietnia"
monthNames[5] = "maja"
monthNames[6] = "czerwca"
monthNames[7] = "lipca"
monthNames[8] = "sierpnia"
monthNames[9] = "wrze¶nia"
monthNames[10] = "paĽdziernika"
monthNames[11] = "listopada"
monthNames[12] = "grudnia"
dayNames = new MakeArray(7)
dayNames[1] = "niedziela"
dayNames[2] = "poniedziełek"
dayNames[3] = "wtorek"
dayNames[4] = "¶roda"
dayNames[5] = "czwartek"
dayNames[6] = "pi±tek"
dayNames[7] = "sobota"
function customDateString() {
currentDate = new Date()
var theDay = dayNames[currentDate.getDay() + 1]
var theMonth = monthNames[currentDate.getMonth() + 1]
msie4 = ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4 ));
if (msie4) {
var theYear = currentDate.getYear()
}
else {
var theYear = currentDate.getYear() +1900
}
return theDay + ", " + currentDate.getDate() + " " + theMonth + " " + theYear + " roku."
}
//-->
</script>
w sekcji <body> wpisz
<script LANGUAGE="JavaScript">document.write(customDateString())</script>
i gotowe
Listing
<head>
<script language="JavaScript">
<!--
function MakeArray(n) {
this.length = n
return this
}
monthNames = new MakeArray(12)
monthNames[1] = "stycznia"
monthNames[2] = "lutego"
monthNames[3] = "marca"
monthNames[4] = "kwietnia"
monthNames[5] = "maja"
monthNames[6] = "czerwca"
monthNames[7] = "lipca"
monthNames[8] = "sierpnia"
monthNames[9] = "wrze?nia"
monthNames[10] = "paĽdziernika"
monthNames[11] = "listopada"
monthNames[12] = "grudnia"
dayNames = new MakeArray(7)
dayNames[1] = "niedziela"
dayNames[2] = "poniedziełek"
dayNames[3] = "wtorek"
dayNames[4] = "?roda"
dayNames[5] = "czwartek"
dayNames[6] = "pi?tek"
dayNames[7] = "sobota"
function customDateString() {
currentDate = new Date()
var theDay = dayNames[currentDate.getDay() + 1]
var theMonth = monthNames[currentDate.getMonth() + 1]
msie4 = ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4 ));
if (msie4) {
var theYear = currentDate.getYear()
}
else {
var theYear = currentDate.getYear() +1900
}
return theDay + ", " + currentDate.getDate() + " " + theMonth + " " + theYear + " roku."
}
//-->
</script>
</head>
<body>
<script LANGUAGE="JavaScript">document.write(customDateString())</script>
</body>
</html>