Time & Date Variables in Storyline

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
Michael Hinze

Hi Ian, I'm not a JavaScript expert either, so I just used a simple JavaScript like this:

var JSdate = new Date();
var JSSeconds = JSdate.getSeconds();
var JSMinutes = JSdate.getMinutes();
var JSHours = JSdate.getHours();
var JSDOM = JSdate.getDate();
var JSMonth = JSdate.getMonth();
var JSDay = JSdate.getDay();
var player = GetPlayer();
player.SetVar("Minutes",JSMinutes);
player.SetVar("Hours",JSHours);
player.SetVar("DOM",JSDOM);
player.SetVar("Month",JSMonth);
player.SetVar("Day",JSDay);

 to get the 'raw' date and time values into Storyline variables. Then, I do the 'conversation' with triggers in Storyline. For example, I convert a JavaScript day value of 5 to 'Friday', etc.

 Here is a sample of the end result.

steven rogers

Michael Hinze said:

Hi Ian, I'm not a JavaScript expert either, so I just used a simple JavaScript like this:

var JSdate = new Date();
var JSSeconds = JSdate.getSeconds();
var JSMinutes = JSdate.getMinutes();
var JSHours = JSdate.getHours();
var JSDOM = JSdate.getDate();
var JSMonth = JSdate.getMonth();
var JSDay = JSdate.getDay();
var player = GetPlayer();
player.SetVar("Minutes",JSMinutes);
player.SetVar("Hours",JSHours);
player.SetVar("DOM",JSDOM);
player.SetVar("Month",JSMonth);
player.SetVar("Day",JSDay);

 to get the 'raw' date and time values into Storyline variables. Then, I do the 'conversation' with triggers in Storyline. For example, I convert a JavaScript day value of 5 to 'Friday', etc.

 Here is a sample of the end result.

Just came across this post and was wondering how you got the time to update. I can get the time to show but it never updates as yours does.

Michael Hinze

steven rogers said:

Michael Hinze said:

Hi Ian, I'm not a JavaScript expert either, so I just used a simple JavaScript like this:

var JSdate = new Date();
var JSSeconds = JSdate.getSeconds();
var JSMinutes = JSdate.getMinutes();
var JSHours = JSdate.getHours();
var JSDOM = JSdate.getDate();
var JSMonth = JSdate.getMonth();
var JSDay = JSdate.getDay();
var player = GetPlayer();
player.SetVar("Minutes",JSMinutes);
player.SetVar("Hours",JSHours);
player.SetVar("DOM",JSDOM);
player.SetVar("Month",JSMonth);
player.SetVar("Day",JSDay);

 to get the 'raw' date and time values into Storyline variables. Then, I do the 'conversation' with triggers in Storyline. For example, I convert a JavaScript day value of 5 to 'Friday', etc.

 Here is a sample of the end result.

Just came across this post and was wondering how you got the time to update. I can get the time to show but it never updates as yours does.

I simply added a trigger at the end of the baselayer's timeline (which is 1sec long.) to jump/loop back to the same slide. This way, the javascript is executed periodically and updates the time.
Dwayne Schamp

Updated version to show just the day of the week, month, day of month, year.

//grab current full date

var JSdate = new Date();

//convert to readable format

var JSFullDate = JSdate.toDateString();

// Get player info

var player = GetPlayer();

// set the Date variable to the readable format

player.SetVar("Date",JSFullDate);

Nuno Cardoso
var currentTime = new Date()
var hours = currentTime.getHours()
var minutes = currentTime.getMinutes()
var weekday=new Array(7);
weekday[0]="Sunday";
weekday[1]="Monday";
weekday[2]="Tuesday";
weekday[3]="Wednesday";
weekday[4]="Thursday";
weekday[5]="Friday";
weekday[6]="Saturday";
var day = weekday[currentTime.getDay()];
var date = currentTime.getDate()
var months=new Array(12);
months[0]="January";
months[1]="February";
months[2]="March";
months[3]="April";
months[4]="May";
months[5]="June";
months[6]="July";
months[7]="August";
months[8]="September";
months[9]="October";
months[10]="November";
months[11]="December";
var month = months[currentTime.getMonth()];
var year = currentTime.getFullYear()
if (minutes < 10)
minutes = "0" + minutes
var timeString=hours + ":" + minutes
var dateString=day + ", " + date + " " + month
var player = GetPlayer();
player.SetVar("SystemDate",dateString);
player.SetVar("SystemTime",timeString);
player.SetVar("systemdateDayOfWeek",day);
player.SetVar("systemdateDay",date);
player.SetVar("systemdateMonth",month);