- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
11-11-2019 03:35 AM
Hi Team,
Can you find me any implementation method wherein I can track time difference between any two events.
I tried using the plugin "s.getTimeToComplete " but for some reason it isnt working.
Any suggestion would be much apprecaited.
Thanks.
11-14-2019 02:51 AM - edited 11-14-2019 02:53 AM
Here is a snippet:
(function () { var currentTimeStamp; var getLastTimeStamp = function () { return window.parseInt(window.localStorage.getItem("teal_last_event_time") || Date.now()); }; var setCurrentTimeStamp = function (epoch) { window.localStorage.setItem("teal_last_event_time", epoch); }; var process = function () { var lastTimeStamp = getLastTimeStamp(); var timeSinceLastEventTimeStamp = Math.abs(currentTimeStamp - lastTimeStamp); var secondsSinceLastEvent = Math.round(timeSinceLastEventTimeStamp / 1000); setCurrentTimeStamp(currentTimeStamp); window.console.log("seconds since last event: " + secondsSinceLastEvent); b["secondsSinceLastEvent"] = secondsSinceLastEvent; }; var init = function () { currentTimeStamp = Date.now(); process(); }; init(); })();
Implementation:
The code will:
Demo:
Copyright All Rights Reserved © 2008-2023