Forum Discussion
How to insert current date variable into a "customised certificate slide".
Hi there,
I have created a certificate looking slide at the end of my course. I have added in variables for the learners name, their score achieved, I am just missing the date variable to be populated automatically.
I have followed the guide on the link below however it has not worked when I have tested it in a clients LMS (SABA). https://vimeo.com/145579723
I was just wondering if anyone could offer any assistance on this matter?
- ALitchfieldCommunity Member
Hi everyone,
I have used this javascript for other instances in my courses, but I'm wondering if I could change it to show the year prior? For example for copyrights, we need to update all to 2020 and If I could create a script to auto-populate the year prior to the current day. Any tips how to do that? TIA!
- WaltHamiltonSuper Hero
Use Matthew's code.
If you mean print year day month, change this line:
var date= dd+' '+m_names[mm]+', '+yyyy
to this:
var date= yyyy+' '+dd+' '+m_names[mm]
or year month day, change it to:
var date= yyyy+' '+m_names[mm]+', '+dd
If you want print the year before this year, change this line:
var yyyy = today.getFullYear();
to this:
var yyyy = today.getFullYear()-1;
- ChristyGibersonCommunity Member
That's for the info!
Is it possible to have the date locked base on when their quiz was completed?
- AudreyHindCommunity Member
Hi there my date is comes up as false. have i missed a set?
- ScottByers-246fCommunity Member
How do I tie the variable to the text box? That is, how do I make the date appear in the box?
- DwayneSchamp-15Community Member
using the above code:
You'll need to add the variable SystemDate to your course. Then insert a textbox on the slide, and enter:
%SystemDate%
This will allow the SetVar to send the "date" information to your course.
The %<varname>% tells SL that this is a variable reference. You can also use the Insert->Reference item in the tool bar, and then use the variable dialog box to select the variable.
HTH
- ScottByers-246fCommunity Member
Thanks, Dwayne! It's a mystery how everyone else already knew this.
- MartinMaynard-1Community Member
Got a challenge for you...
Can you do this system date code plus three days?
I am needing "today's" date to be displayed, plus the date 3 days after "today's"
Is this possible?- LaraBeltran-6c0Community Member
I have the same problem right now. I hope there was an answer for this.
- LaraBeltran-6c0Community Member
I have the same problem right now. I hope there was an answer for this.
- DuaneStitt-8471Community Member
Thank you, Chat GPT. Here is the javascript for showing the date three days in the future.
var m_names = new Array("January", "February", "March",
"April", "May", "June", "July", "August", "September",
"October", "November", "December");
var today = new Date();
today.setDate(today.getDate() + 3); // Add three days
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);
- WilliStolz-29f0Community Member
Thank you Joanne Chen and others!
- JasonHangerCommunity Member
I could not get this to work. What should be in the text box? I cannot have a blank text box. I tried "SystemDate" and "= %system_date%" as placeholder text but nothing worked.