Forum Discussion
Update a variable with the current date and time
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);
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.
Related Content
- 10 months ago
- 10 months ago
- 10 months ago