JavaScript Current Date Coding - Using Full Month, Day and Year (i.e. January 1, 2015)

Feb 20, 2015

I would like to add the date variable to a completion certificate. I have the JavaScript coding to capture the current system date, however, I want to ensure that the date locks and doesn't change each time the SCORM is accessed. Also, I want to display the date as full month description, day and year (i.e. January 1, 2015). Does anyone have the JavaScript coding for full month, day and year, with the lock down feature?

 

Thanks

Sandy

33 Replies
Gene Rukavina

Here is the code that I went with and it works perfectly:

var m_names = new Array("January", "February", "March",
"April", "May", "June", "July", "August", "September",
"October", "November", "December");
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth();
var yyyy = today.getFullYear();
if(dd<10) { dd='0'+dd }
var date= m_names[mm]+' '+dd+', '+yyyy;
var player = GetPlayer();
player.SetVar("SystemDate",date);

Alicia Blitz

Hi Jackson, I was looking in the archives trying to find some script to take the current date and modify it for a simulation. Basically I want to take the day the learner is taking the course a create 4 variables to be displayed in the simulation:

Last Payment date 1 = previous month on the 1st of the month

Last Payment date 2 = previous month on the 15th of the month

Due Date 1 = next month on the 1st of the month

Due Date 2 = next month on the 15th of the month

 

This will keep the dates fresh in the course.

 

Any ideas? Thanks!

 

A~

 

This discussion is closed. You can start a new discussion or contact Articulate Support.