Forum Discussion
Date Variables available?
Hi there - just curious to know if it's possible to have a date variable populated in Storyline?
So the course can show the date the course is being taken...
I'm thinking about using such a feature for a completion certificate.
thanks!
23 Replies
- JamesBrandwoodCommunity Member
Thanks Brian!
This should work great - I have to simulate a button that inserts todays date and this should do it. As I only want the date to appear when they press the buton i will just do a trigger to change the state to make it 'appear'.
- DanielYorkCommunity Member
Hi Brian,
I have tried many different things trying to get your variables working. I thought maybe it was my project causing a glitch, so I started a new project with a blank slide just like your tutorial (I have watched now about 30 times). But still no success. I can not figure out what I am doing wrong. Any help? Attached is the blank slide for your reference.
- DanielYorkCommunity Member
if I use the story_html5.html file as opposed to story.html then it works in all my browsers.
Hi Daniel and Welcome to E-Learning Heroes! So, are you good-to-go now, or did you still have a question. Just want to be sure that I have not missed anything. Thanks so much and have a great day!
- CurtZilbersherCommunity Member
Could anyone (or Brian) please tell me how to modify Brian's javascript so that I can get the current date minus x number of days. The script needs to recognize that the result has to be an actual date; not a negative number. So, if it's only 12/3/2013, subtracting 5 days shows 12/28/2013, NOT 12/-2/2013.
Here's the script which works to get today's date:
var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
var dateString=month + "/" + day + "/" + year
var player = GetPlayer();
player.SetVar("SystemDate",dateString); - YeonhaKwak1Community Member
I spend all this afternoon but I can't get the date. It is blank........
Please help me what is wrong??
- MichaelHinzeCommunity Member
Assuming that you are using the code snippet in the post above, make sure that you have a Storyline variable 'SystemDate' defined.
- NancyWoinoskiSuper Hero
Also, just to add to what Michael is saying, most browsers will not run the JavaScript when you run the course locally on your PC. To test properly you have to upload the course to a web server or LMS.
Hi Jenny,
To back up what Nancy said, if you aren't ready to upload to your LMS or web server yet, you could look at testing it out at tempshare.articulate.com or using Amazon S3 as a web server. The directions here will walk you through how to set up an Amazon S3 account.
- MichelleMcKinneCommunity Member
Fantastic solution, many thanks Brian.
Posting a further query here in case anybody has already figured this out. :)
I wish to display my date format as 01/Jan/2018.
I have figured out the "Jan" bit (using https://stackoverflow.com/questions/27480262/get-current-date-in-dd-mon-yyy-format-in-javascript-jquery)
but I am struggling a little to display the day as "01" and not just "1".
Solutions?
My current javascript command reads:
var m_names = new Array("Jan", "Feb", "Mar",
"Apr", "May", "Jun", "Jul", "Aug", "Sep",
"Oct", "Nov", "Dec");
var currentTime = new Date();
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate();var year = currentTime.getFullYear();
var dateString=day + "/" + m_names[month] + "/" + year;
var player = GetPlayer();
player.SetVar("systemdate",dateString)- Bernovan-SoestCommunity Member
function getDayFormatted (iDay){
var day = iDay;
return day < 10 ? '0' + day : day;
}
Thanks Berno for sharing here! This discussion is a bit older, but I'm certain the ideas may help others who come across it!
Related Content
- 12 months ago
- 12 months ago
- 12 months ago
- 12 months ago