Forum Discussion
Date Format for System Date
Thank you!!! I am learning so much from everyone here and this is what I was able to gather from everyone here and resources elsewhere.
Javascript - using a variable to call the current date and an expiration date 180 days later
Code 1 System Date
var currentTime = new Date()
var month = currentTime.getMonth() + 1
if(month<10);
{
month='0' + month;
}
var day = currentTime.getDate()
var year = currentTime.getFullYear()
var dateString=month + "/" + day + "/" + year
var player = GetPlayer();
player.SetVar("SystemDate",dateString);
Code 2 Expire Date - 180 days later
var someDate = new Date();
var numberOfDaysToAdd = 180;
someDate.setDate(someDate.getDate() + numberOfDaysToAdd);
var dd = someDate.getDate();
var mm = someDate.getMonth() + 1;
var y = someDate.getFullYear();
var dateString = mm + "/" + dd + "/" + y;
var player = GetPlayer();
player.SetVar("ExpireDate",dateString);