Forum Discussion
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 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
- MichaelHinzeCommunity Member
Just for fun, here are two examples of clocks I built a long time ago.
- UshwinPaiCommunity Member
Brilliant!! Thank you! I will get onto that asap and try it out!
- UshwinPaiCommunity Member
https://www.clocklink.com/gallery/view/html5-004
How do I find the direct link to this clock? I need to have a transparent clock to fit over an image of an iPad. - UshwinPaiCommunity Member
- UshwinPaiCommunity Member
Thanks for helping so much here. It's hugely appreciated.
One thing - on the link you just gave, I can make the clock appear - but no transparent background even if I select transparent. Have you had any luck there?- OwenHoltSuper Hero
Don't be afraid of JavaScript. Here are the steps and the code you need.
- Create a text variable in your project. I named mine "DisplayTime" and gave it a default value of 0:00 for testing but you can leave the default blank.
- Execute JavaScript when the timeline starts, on your first slide. Here is the JavaScript:
// Establish StoryLine player connection
var player=GetPlayer();// Check time, update it every second, send result to StoryLine
var myVar = setInterval(myTimer, 1000);
function myTimer() {
var d = new Date();
var dT = d.toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'});
player.SetVar("DisplayTime", dT);
} - Everywhere you want the time displayed in Storyline, add a text box with your variable's name included between two % signs. Like this: %DisplayTime%
See example here: https://360.articulate.com/review/content/1d37a5f8-f200-450d-a12a-3b37d8043c41/review
Because you are using a text box to display the time, the background will be transparent.
- UychhorngKhan-8Community Member
Thank you so much, Owen. It's really helpful. Would you mind if you could show me how to trigger this DisplayTime to the result slide when the clock reaches 5 pm daily for example?
I have been searching around the community for a while and didn't find the solution yet. Thank you in advance.
- PhilMayorSuper Hero
I was going to suggest what Owen suggests.
Nice solution Owen!
- PhilMayorSuper Hero
Just one edit needed to your post Owen, the variable should be DisplayTime in Storyline
- OwenHoltSuper Hero
I was typing quickly. LOL
Thanks for catching my variable "name switch".
- UshwinPaiCommunity Member
Amazing! Thanks. I will have a go (I am an absolute novice at Javascript - so thank you for the code). I will give it a go!
- UshwinPaiCommunity Member
Works brilliantly! Thank you!
- UshwinPaiCommunity Member
Where is it referencing the time from? PC or Internet? Local PC I assume?
- PhilMayorSuper Hero
Javascript will always be the local machine