Forum Discussion
UshwinPai
5 years agoCommunity Member
Actual clock showing actual time
Hi guys
Spent a while looking for the answer, and trying to build it myself - but to no avail! I want to make a digital clock that works to show the real world time on screen. I am building a f...
DiarmaidCollins
Community Member
Via ChatGPT. I asked it to amend the code to a function and add an interval for seconds. This is the code it produced and it works:
function updateTime() {
const date = new Date();
const time = date.toTimeString();
const hours = time.substring(0,2);
const minutes = time.substring(3,5);
const seconds = time.substring(6,8);
var player = GetPlayer();
player.SetVar("H",hours);
player.SetVar("M",minutes);
player.SetVar("S",seconds);
}
setInterval(updateTime, 1000);
PhilMayor
2 years agoSuper Hero
That is cool, glad you got it sorted.
Sent from my iPhone