Answer the question
In order to leave comments, you need to log in
How to overwrite a variable every day (after 24 hours)?
On the site I use the plugin to animate counters countUp.js
Here is the code that I use on the site
var options = {
useEasing : true,
useGrouping : true,
separator : '',
decimal : '.',
prefix : '',
suffix : ''
};
var developer_users = 75000;
var developer = new CountUp("developer", 0, developer_users, 0, 6.5, options);
var talent = new CountUp("talent", 0, 6, 0, 5, options);
var growth = new CountUp("growth", 0, 25, 0, 4, options);
var colleges = new CountUp("colleges", 0, 800, 0, 6, options);
developer.start();
talent.start();
growth.start();
colleges.start();
Answer the question
In order to leave comments, you need to log in
var developer_users = function() {
var start = new Date('2015.10.10');
var now = new Date();
var days = Math.floor(((now - start) / 86400000));
return 75000 + days * 3;
}();
To prevent the counter from being reset when updating, you need LocalStorage
To update the counter every 24 hours, you need to do something like this script, which, for example, will check the date every second
setInterval(function () {
var now = new Date();
var hour = now.getHours();
var min = getMinutes();
// а дальше сравниваем с этолоном, например с 0 часов 0 минут 0 секунд
// обновляем счетчик и сохраняем его в localStorage
}, 1000)
1) store on the server and transfer from the server
2) date function: f(x) = (dateNow-x).getDaysTotal()*3
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question