Instead of using a new session variable for each individual timer, I would create one Tracker.Dependency , which is marked for changes every second (or maybe every 10 seconds), and then depends on it when you want to depend on the current time .
var timeTick = new Tracker.Dependency(); Meteor.setInterval(function () { timeTick.changed(); }, 1000); fromNowReactive = function (mmt) { timeTick.depend(); return mmt.fromNow(); } Template.example.helpers({ example: function () { return fromNowReactive(moment().startOf('hour')); } });
This is the approach taken by mizzao:timesync , which is a useful package that you can use if those fromNow side timestamps. One reason not to use timestamps generated by the client is that they may not be synchronized, which results in lines like 5 seconds from now for the message that has just been made. mizzao:timesync allows you to use omnidirectional server timestamps everywhere, as well as effectively group different reactivity intervals.
source share