Calling all JavaScript wizards [SOLVED]

I have a script for showing the “last modified date”. Unfortunately, it is showing the date in the wrong format and I don’t know first thing about JavaScript. I know there is someone in this forum who could help me, though. :grin:

Here is the script:

<script type="text/javascript" language="JavaScript">
      <!-- 
      function dayofWeek(day)
      {
       switch( day ) {
       case 0: s = "Niedziela"; break;
       case 1: s = "Poniedziałek"; break;
       case 2: s = "Wtorek"; break;
       case 3: s = "Środa"; break;
       case 4: s = "Czwartek"; break;
       case 5: s = "Piątek"; break;
       case 6: s = "Sobota"; break;
       default: s = "Unknownday"
       }
       return s;
      }
      function monthofYear(mon)
      {
       switch( mon ) {
       case 0: s = "Styczeń"; break;
       case 1: s = "Luty"; break;
       case 2: s = "Marzec"; break;
       case 3: s = "Kwiecień"; break;
       case 4: s = "Maj"; break;
       case 5: s = "Czerwiec"; break;
       case 6: s = "Lipiec"; break;
       case 7: s = "Sierpień"; break;
       case 8: s = "Wrzesień"; break;
       case 9: s = "Październik"; break;
       case 10: s = "Listopad"; break;
       case 11: s = "Grudzień"; break;
       default: s = "Unknownmonth"
       }
       return s;
      }
      
      lastmod = document.lastModified  	         // get string of last modified date
      lastmoddate = Date.parse(lastmod) 	         // convert modified string to date
      if(lastmoddate == 0){               	         	// unknown date (or January 1, 1970 GMT)
         document.writeln("Last Modified: Unknown")
      } else {
     d = new Date(lastmod);
      document.write("Day=", day=dayofWeek(d.getDay()), ", ");
      document.write("Month=", mon=monthofYear(d.getMonth()), ", ");
      document.write("Date=", dte=d.getDate(), ", ");
      document.write("Year=", year=d.getYear(), "<br>");      
      document.write("Ostatnia aktualizacja: ", day + ", " + dte + "  " + mon + ", " + year);
      }// -->
    </script>

As a result, this script shows in Preview mode like this:

What I need is to get rid of the entire first line in the displayed text and to fix the year, retaining the language localisation and the sequence of: dayofWeek/date/month/year. If you know the way to simplify/shorten this script without loosing above mentioned requirements, go ahead, please.

Best regards,
Rob

Never mind, guys. I worked it out – meaning – I found another script that I modified to my needs. Works as expected.

1 Like
<script>
      function dayofWeek(day)
      {
       switch( day ) {
       case 0: s = "Niedziela"; break;
       case 1: s = "Poniedziałek"; break;
       case 2: s = "Wtorek"; break;
       case 3: s = "Środa"; break;
       case 4: s = "Czwartek"; break;
       case 5: s = "Piątek"; break;
       case 6: s = "Sobota"; break;
       default: s = "Unknownday"
       }
       return s;
      }
      function monthofYear(mon)
      {
       switch( mon ) {
       case 0: s = "Styczeń"; break;
       case 1: s = "Luty"; break;
       case 2: s = "Marzec"; break;
       case 3: s = "Kwiecień"; break;
       case 4: s = "Maj"; break;
       case 5: s = "Czerwiec"; break;
       case 6: s = "Lipiec"; break;
       case 7: s = "Sierpień"; break;
       case 8: s = "Wrzesień"; break;
       case 9: s = "Październik"; break;
       case 10: s = "Listopad"; break;
       case 11: s = "Grudzień"; break;
       default: s = "Unknownmonth"
       }
       return s;
      }
      
      lastmod = document.lastModified  	         // get string of last modified date
      lastmoddate = Date.parse(lastmod) 	         // convert modified string to date
      if(lastmoddate == 0){               	         	// unknown date (or January 1, 1970 GMT)
         document.writeln("Last Modified: Unknown")
      } else {
      d = new Date(lastmod);
      day=dayofWeek(d.getDay());
      mon=monthofYear(d.getMonth());
      dte=d.getDate();
      year=d.getFullYear();
      document.write("Ostatnia aktualizacja: ", day + ", " + dte + "  " + mon + ", " + year);
      }

</script>

– Never mind? :wink:

Thanks, Stuart, I got it already, but I knew that if somebody would pick up this topic, that would be you… :kissing_heart:

2 Likes