Forum Discussion
Java script for days name and month name
Please share javascript for fetching weekdays name and month name on LMS or Scorm. Format given in attachment for reference.
- TracyParishSuper Hero
I'm don't know javascript, but I have found this in the past and have used it in a course. It's a start and someone else might correct it here.
On my first course slide I added this javascript:
function fixDigit(val){
return val.toString().length === 1 ? "0" + val : val;
}
var player = GetPlayer();
var d = new Date();
var months = ["January","February","March","April","May","June","July","August","September","October","November","December"];
var year = d.getFullYear();
var hours = d.getHours();
var minutes = d.getMinutes();
sInfo = months[d.getMonth()] + " " + d.getDate() + ", " + year;
player.SetVar("SystemDate",sInfo);
sInfo = fixDigit(hours) + ":" + fixDigit(minutes);
player.SetVar("StartTime",sInfo); - TracyParishSuper Hero
Example image: