Actual clock showing actual time

Sep 23, 2020

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 fake tablet, which learners can interact with within a game, and a nice touch would be the clock on the lock screen showing the actual time in the world!

Any ideas how this could be done? (FYI I am a 0/10 when it comes to Java!)
Thanks

25 Replies
Diarmaid Collins

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);
Diarmaid Collins

Just in case anyone is interested, I have been keeping a file with all different snippets of time-related coding for a while and have compiled them into a demo module to test out on.

Here is a link to the demo in Review:

DateTimeTest | Review 360 (articulate.com)

The coding is listed above the blue execute buttons. Lots of the coding use the same base variables, so that is why when one clicks one button, values may change elsewhere. It was to kind of help me wrap my head around javascript, but I realise now that it is pointless. Everyone has different styles and methodologies, and I have just now discovered that ChatGPT can break down and analyse code and explain it to you, and also generate its own clean code. Amazing.

Here is a link to the Storyline file if anyone wants to yoink a particular bit of code from it:

https://www.dropbox.com/s/ihijnp3ez04mf6n/DateTimeTest-2023.story?dl=0