Forum Discussion
Store today's date as a variable
- 2 months ago
You need a code similar to this:
// Get the current date
var currentDate = new Date();
// Array of month names
var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
// Get day, month, and year
var day = currentDate.getDate();
var monthIndex = currentDate.getMonth();
var year = currentDate.getFullYear();
// Format the date into a single string
var formattedDate = months[monthIndex] + ' ' + day + ', ' + year;
// Set the variable value in Storyline
GetPlayer().SetVar('currentDate', formattedDate);
You will insert this code into a trigger to run JS.
In Storyline, you need to create a text variable called currentDate and display it on the screen in the desired location.
Hi there, thanks for your reply. I'm looking for something close, basically date formatted "long date" (e.g., October 10, 2024)
- Jonathan_Hill2 months agoSuper Hero
Cool, OK, this code can do both! I'm away from my desk right now, but I'll post it here in a couple of hours.