Forum Discussion
TinaDenmark-558
8 months agoCommunity Member
Convert systemDate to static txt
I created a variable, systemDate, using JavaScript to display the completion date on a certicate. However, the date changes when the certificate is revisited.
Does anyone know how I can conver...
Nedim
8 months agoCommunity Member
Try this code:
var dateString;
// Check if dateString has been previously defined
if (typeof dateString === 'undefined') {
// If not, generate the date
var currentTime = new Date();
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate();
var year = currentTime.getFullYear();
dateString = month + "/" + day + "/" + year;
var player = GetPlayer();
player.SetVar("systemDate",dateString);
}
In case the provided code doesn't function as intended, an alternative approach is to store the 'dateString' in a variable or a persistent storage medium, such as a localStorage. By doing so, you can easily retrieve the stored date whenever required.