annahino
4 years agoCommunity Member
live dynamic date and time with javascript
Just want to share here my code for a dynamic date and time -
So if someone want to have the date and the time in their slide updating live, this is the code:
function dateAndTime(){
let currentTime = new Date();
let monthArray = new Array ("January","February","March","April","May","June","July","August","September","October","November","December");
let month = currentTime.getMonth();
let monthName = monthArray[month];
let day = currentTime.getDate();
let year = currentTime.getFullYear();
let hour = currentTime.getHours();
let minute = String(currentTime.getMinutes()).padStart(2, "0");
let second = String(currentTime.getSeconds()).padStart(2, "0");
let dateString= day + " " + monthName + " " + year + " " + hour + ":" + minute + ":" + second ;
let player = GetPlayer();
player.SetVar("SystemDate",dateString);
setTimeout( dateAndTime , 1000);
}
dateAndTime();