Forum Discussion
Update a variable with the current date and time
Is it possible to insert the date and time into a variable to be displayed on screen.
What I want to achieve:
To time an activity that takes place over a number of slides.
Happy to use Javascript - any help is appreciated.
40 Replies
- RenGomezStaff
Hi Ionut,
You can also feel free to reach out to Michael directly by clicking on his profile and using the Contact Me button!
- TiffanyDorrisCommunity Member
Not sure if anyone still following this thread, I did reach out to some people individually.
Here is my question:
I am using the following javascript to display the learner's current time in my course.
______________________
var player = GetPlayer();
function date_time() {
var date = new Date();
var am_pm = "AM";
var hour = date.getHours();
if(hour>=12){
am_pm = "PM";
}
if(hour>12){
hour = hour - 12;
}
if(hour<10){
hour = "0"+hour;
}var minute = date.getMinutes();
if (minute<10){
minute = "0"+minute;
}
player.SetVar("12Hour", hour+":"+minute+" "+am_pm);}
setInterval(date_time,500);
_________________________________
It is working beautifully. However, there are a few places where the learner completes a process and I want to take a timestamp of when they push the hotspot to start the process. So if they click the hotspot at 1:00 pm, it will show 1:00 pm on all the following slides. Is there a way to do this? I can't use the reference to the existing variable because the time changes. So I am assuming I need a new javascript for the timestamp. Any help would be much appreciated! (Note - I don't know how to write code, I just know how to copy and paste! Be gentle!) LOL
Thank you!
Related Content
- 10 months ago
- 10 months ago
- 10 months ago