Forum Discussion
- TomasCampoma312Community Member
This was totally helpful! From 7 years in the future, thanks Joanne.
- SammSchmidtCommunity Member
I copied Joanne's code from above and created a trigger:
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);and added the text variable SystemDate (I even tried it with a different variable and updated the code accordingly) I set up my trigger to execute the javascript when the timeline starts on this slide, I have a text box with %SystemDate% and I am not able to see the date print on the slide when in Review360. Is this a known bug or is there an issue with my above code? I know zero javascript so I am at a loss for what Is going wrong here.
- Jürgen_Schoene_Community Member
no - nothing special for Review 360
here is a working example (with modern Javascript)
player = GetPlayer();
var date = new Intl.DateTimeFormat('en-us', {
year: "numeric",
month: "long",
day: "numeric"
}).format();
player.SetVar("SystemDate", date);result:
https://360.articulate.com/review/content/6166e558-462b-4a16-a506-0ecb1d507221/review
- SammSchmidtCommunity Member
thanks got it working!
- WaltHamiltonSuper Hero
For this to work, SL needs to have a variable named SystemDate. Then %SystemDate% will show the contents of the SystemDate variable. Be sure to use a text box, and not a text entry box, or the learner will be able to change it.
After it is created, %SystemDate% can be inserted with Insert -> Reference, or you can just type it in, but that is vulnerable to not working if typed incorrectly.
- 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.
- WilliStolz-29f0Community Member
Thank you Joanne Chen and others!
- 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.
- 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);
- LaraBeltran-6c0Community Member
I have the same problem right now. I hope there was an answer for this.
- ScottByers-246fCommunity Member
Thanks, Dwayne! It's a mystery how everyone else already knew this.
- 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
How do I tie the variable to the text box? That is, how do I make the date appear in the box?
- AudreyHindCommunity Member
Hi there my date is comes up as false. have i missed a set?