Time & Date Variables in Storyline
Aug 22, 2013
By
Ian Mondrow
Hi All,
I saw the posting to help the discussion regarding insert the current date into the course using a javascript. However, it puts the date in MM/DD/YYYY format. How would you go about putting the date into a format like,"Thursday, August 22"?
Also, how would you write a javascript to show the current time? I don't need a timer, but an actual clock. I found a few javascripts online (http://www.quackit.com/javascript/tutorial/javascript_date_and_time.cfm) but they didn't work. I think its because they are not articulate specific.
I am completely new to java so I have no idea how to write them from scratch. Any help is appreciated!!!
57 Replies
Hi Nuno,
If I understand, the timer will only work if the used layout is the one with the timer?
This is looks fine.
Unfortunately it is not a kind of timer of the whole e-learning
Would be fine if I could grab somewhere the time the scorm/tin can package has been launched
Any idea on how to do this?
Bruno! Excellent! This answers something I have been puzzling over off and on for a week. Thank you, sir!
This exciting because I am trying to figure out if I can add the current date to a certificate of course completion. I am very new to Storyline, so not sure how to insert the code above into Storyline 2?
You can cut&paste JS code into an Execute Javascript trigger. Make sure that you also create the Storyline variables that are used in the JS code.
Thank you, Michael!
I figured it out. I am constantly amazed by the power of Storyline!
This online community is second to none. I am very impressed. :)
Hello, all!
I just thought I should stop in to note for anyone who is considering using JS as an option, unfortunately, we are not able to provide support for JavaScript coding. Luckily, we have lots of community members who are more than willing to share their expertise to assist!
And for those who'd like to review it, here is a sheet on JavaScript Best Practices you may want to keep handy. :)
Thanks, Christie!
Hi Nuno, thanks for sharing.
I am having troubles getting the script to work for me. I am actually wanting to modify it a bit too.
I am creating a TV screen and want to have a guide option. I want to replicate the day_date format on the left and also want the times across the top be relative to the current time. Here's a sample of wat I am trying to replicate:
I included a file below.
Hi Alicia! Check the link bellow. Is this what you intend to achieve?
http://informatic.com.pt/storyline/remote/
Regards
Wow Nuno. that's pretty darn close! I was hoping the replicate the day/date like this:
But the full day name works too. :)
I guess have an obsession about fully replicating the enivronment!
Alicia, please check it out now :)
Regards.
That's perfect! How did you do that?
Hi Alicia, sorry for the late reply. :)
So, lets see the code. See comments bold
See file attached :)
Hope this helps you solve the issue.
Regards
Thanks for sharing that code here Nuno - and hope it helps others who come across this too.
Nuno this is amazing, thank you so much! Your explanations here are very helpful. I made one slight change the make it even more like the guide, by changing the minutes to always be 00. I managed to not disrupt any of the code and I actually understand how you did it! This is very exciting.
Many thanks again for your assistance, my boss is going to be blown away! :)
Thats great! Yehaaaa! :)
I was also able to figure where to insert some code I found to convert from 24 hr to 12 hr. YEAH!
Thanks for sharing those updates and the code you're using here Amy, as I suspect that'll help others who come across this thread.
how do you convert the time from 24 hour to 12?
Hey Tim - Not sure if Nuno is still subscribed here, but it looks like Alicia shared how she converted the same above in her response. Perhaps that can assist you as well. If not, you are welcome to reach out to the users directly via the 'Contact Me' option on the user profile if you do not hear back soon.
Hi Tim,
check if this is what you are trying to accomplish.
http://informatic.com.pt/storyline/timer_1/
Hi Nuno,
I was working on another project and was trying to modify the script. It's not working at all.
I am trying to modify the current system date the learner is taking the course to simulate a loan screen with the Due Date, Bill Date, and Last Payment Date.
Here's what I have so far:
\\These are setting the months for both Mortgage and Loan
var currentTime = new Date()
var currentMonth = currentTime.getMonth() + 1
var dueMonth = currentTime.getmonths() + 2 //This variable gets current month + 1
var billMonth = currentTime.getmonth() //This variable gets previous month
var LastPmtMonth = currentTime.getmonth() //This variable gets previous month
\\These are setting the dates for both Mortgage and Loan
var day = currentTime.getDate()
var dayLastPmtL ="15" //This is setting the Last Pmt Date day to the 15th
var dayLastPmtM ="1" //This is setting the Last Pmt Date day to the 1st
var dayDueDateL ="15" //This is setting the Due Date day to the 15th
var dayDueDateM ="1" //This is setting the Due Date day to the 1st
var dayBillDateL ="1" //This is setting the Due Date day to the 1st
var dayBillDateM ="16" //This is setting the Due Date day to the 16th
var year = currentTime.getFullYear()
var dateString=month + "/" + day + "/" + year
var player = GetPlayer();
player.SetVar("SystemDate",dateString);
\\These are setting the Due Dates for both Mortgage and Loan
var dateStringDueDateM=dueMonth + "/ " + dayDueDateM + "/ " + year
var player = GetPlayer();
player.SetVar("DueDateM",dateStringDueDateM);
var dateStringDueDateL=dueMonth + "/ " + dayDueDateL + "/ " + year
var player = GetPlayer();
player.SetVar("DueDateL",dateStringDueDateL);
\\These are setting the Bill Dates for both Mortgage and Loan
var dateStringBillDateM=billMonth + "/ " + dayBillDateM + "/ " + year
var player = GetPlayer();
player.SetVar("BillDateM",dateStringBillDateM);
var dateStringBillDateL=billMonth + "/ " + dayBillDateL + "/ " + year
var player = GetPlayer();
player.SetVar("BillDateL",dateStringBillDateL);
\\These are setting the Last Pmt Dates for both Mortgage and Loan
var dateStringLastPmtM=LastPmtMonth + "/ " + dayLastPmtM + "/ " + year
var player = GetPlayer();
player.SetVar("LastPmtM",dateStringLastPmtM);
var dateStringLastPmtL=LastPmtMonth + "/ " + dayLastPmtL + "/ " + year
var player = GetPlayer();
player.SetVar("LastPmtL",dateStringLastPmtL);
Hi Alicia,
I'm not sure if folks are still subscribed here, as the post is a bit older - but you could always use the "contact me" button on a ELH users' profile to reach out to them directly!
As for the variables, if you're using Storyline 3 or Storyline 360, that may be why they're not working as expected. With the changes that were made to our publishing engine, it removed access to some of these system variables that were hidden before (although found/uncovered by users such as yourself). I know a few folks have shared their methods around those changes here in ELH - but it's not something I'm equipped to assist with. I hope you find the help needed!
Could you help me out with getting current time on articulate story line.
Hi Varun,
This discussion is quite a bit older, so you may want to share a bit more detail on what you're looking to set up. It'll be helpful for folks in the community to know the version/update of Storyline you're using, where you're hosting your project, and if you're hoping to use Javascript or another method to pull this information.
Also, you could always use the "contact me" button on a ELH users' profile to reach out to them directly! Best of luck with your project!
This discussion is closed. You can start a new discussion or contact Articulate Support.