Forum Discussion
OnboardingTeam
3 years agoCommunity Member
Show a date X number of days before today's date on Storyline - is this possible?
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 ...
RandyWalker2
3 years agoCommunity Member
/* Create new variable to hold date */
var d = new Date();
/* For example: write today's date in specified locale's format 29/08/2023 */
document.write('Today is: ' + d.toLocaleDateString("en-GB"));
/* Set our variable to the date of 5 days ago. We can do the math right here! You could use a variable here if it's something you want to change */
d.setDate(d.getDate() - 5);
/* Example: write out 5 days ago in specified locale's format 08/24/2023 */
document.write('<br>5 days ago was: ' + d.toLocaleDateString("en-US"));
Related Content
- 7 months ago
- 2 years ago
- 8 months ago
- 8 months ago
- 9 months ago