I have figured out how to pull today's date using Javascript. However, I want to generate a date that is X amount of days before today's date. For example, today shows as 30/08/2023. I want to show 01/08/2023 on the same slide.
The javascript I have used to show todays date is:
let currentTime = new Date();
let month = currentTime.getMonth() + 1;
let day = currentTime.getDate(); let year = currentTime.getFullYear();
// Putting it together let dateString = day + "/" + month+ "/" + year;
//Pushing data to Storyline let player = GetPlayer(); player.SetVar("todaysDate", dateString);
I'm also looking for Javascript to show 15 days prior to today's date in the format of MM/DD/YYYY, but everything I've tried so far in the wrong format or shows a negative number for the date. The previous reply shows it in a document, but I need to use it as a variable in Storyline. I'm new to Javascript, so I'm not sure what changes need to be made.
4 Replies
I'm also looking for Javascript to show 15 days prior to today's date in the format of MM/DD/YYYY, but everything I've tried so far in the wrong format or shows a negative number for the date. The previous reply shows it in a document, but I need to use it as a variable in Storyline. I'm new to Javascript, so I'm not sure what changes need to be made.
Hi Tina, you can try this code:
Jordan,
That worked perfectly. Thank you!