Forum Discussion
Convert systemDate to static txt
That's correct, Phil. However, with this code, the value of the 'dateString' variable will not persist, so during preview, it will keep displaying today's date. When you come back to it tomorrow, it will display 3/28/24. I was trying to achieve something else with less code. The localStorage version should look something like this:
var dateString = localStorage.getItem('certificateDate');
if (!dateString) {
var currentTime = new Date();
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate();
var year = currentTime.getFullYear();
dateString = month + "/" + day + "/" + year;
localStorage.setItem('certificateDate', dateString);
}
var player = GetPlayer();
player.SetVar("systemDate", dateString);
This code will run properly in preview as well.
Tina,
I have attached the .story file for reference. Please disregard the first JavaScript trigger, as it always shows the current date.