Articulate Storyline

How to Detect Time in Articulate Storyline 360 Using JavaScript

In this video, I show you how to use JavaScript snippets inside Articulate Storyline 360. Specifically, how to detect the current time of the user taking the course and then, depending on the time of day, adjust a variable inside of Storyline 360 to adjust content on the stage in your eLearning courses.

This JavaScript snippet especially comes in handy when working with content that changes the time of day. For example, you could reference contacting IT if it is within business hours but then change the text to tell the user IT is closed right now and when they can contact IT the next day. Being able to detect the time from the browser and then change your content based on the time could be extremely useful to personalize your learning content to each user, depending on the time of day they take the course.


// Get Date Info
let currentDate = new Date();
let hours = currentDate.getHours();
let minutes = currentDate.getMinutes();

//Combine both
let timeStamp = hours + ":" + minutes;

//Pushing data to Storyline
let player = GetPlayer();
player.SetVar("currentTime", timeStamp);
player.SetVar("hours", hours);

Jeff Batt
28 Nov, 2023