Forum Discussion
Update a variable with the current date and time
Hello David,
could you tell me how the time code works for Germany? We Count 24 Hours a day without AM or PM.
Thank you very much.
I think this simplified script here should do the trick;
var currentDate = new Date();
var day = currentDate.getDate();
var month = currentDate.getMonth() + 1;
var year = currentDate.getFullYear();
var player = GetPlayer();
var newName = day + "/" + month + "/" +year
player.SetVar("DateValue", newName);
var currentTime = new Date();
var hours = currentTime.getHours();
var minutes = currentTime.getMinutes();
var CurTime = hours + ":" + minutes;
player.SetVar("TimeValue",CurTime);
- MartinVolckart7 years agoCommunity Member
Hello Michael,
perfect! Thanks a lot for your invaluable help.
Best regards
Martin
Von: E-Learning Heroes [mailto:heroes@articulate.com]
Gesendet: Donnerstag, 8. November 2018 17:24
An: Martin Volckart
Betreff: Reply to Update a variable with the current date and time- MichaelHinze7 years agoCommunity Member
I just realized my earlier script suggestion would not account for hours and minutes< 10. They would be shown like "9:9". See attached a quick update that fixes this issue to show the hours and minutes always with two digits, e.g. "09:09". Here is the published example.
- IonutMarin-9e526 years agoCommunity Member
hi Michael,
since you rock on JavaScript, do you know how to add x hours between quiz attempts?
thank you!
Related Content
- 10 months ago
- 10 months ago
- 10 months ago
- 10 months ago