Java script for days name and month name May 17, 2022 By Monika Mehta Please share javascript for fetching weekdays name and month name on LMS or Scorm. Format given in attachment for reference. Capture.PNG
Parish.tracy@gmail.com Parish Hero almost 2 years ago05/17/22 at 5:12 pm (UTC) 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);
2 Replies
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);
Example image: