Date Variables available?

May 10, 2012

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
Raymond Wan

Hey Brian, thanks for the tip....

I'm not too familiar with Java though...i've tried reviewing your job aids but can't get a date to appear on a slide.

Any way you could take a moment to walk me through it? 

Do I need to have a trigger in place in order to have a date appear on the slide?

Apologies....

mike mcdonald

I've been thinking of a simple way of inserting an expiry date into a standalone presentation (I mean one that is not within an LMS).

Example application - if I made a sample presentation and emailed it out, but I wanted to prevent it being viewed past a certain date.

 I haven't come across any way yet, so I wonder if this method could be used to do that - by coding in the 'currentdevelopment date' into the javascript that Brian demonstrated....and then if I only wanted the presentation to be viewable for the next 2 months say, I would make a sum that took the 'user system date' minus 60, and if it was positive, jump to a branch that ended the presentation (as it was being viewed more than 2 months in the future).

Does that sort of make sense? Sorry, if I've missed a really simple way of achieving the same thing - just haven't found a way yet!

Cheers

D None

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.

Curt Zilbersher

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);

Michelle M

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)

Matt Painter

I am working on an elearning and need to display a date based on the next available day. The scenario I am working with is a lawyer is only available on Tuesdays for a meeting. If the user taking the module on Thursday 07/15/2021 the date I need displayed in the module would be 07/20/2021. 

Is this possible using Javacoding? If so, could someone help me with how the code would need to be written? 

thank you!