Reputation: 145
I use flip clock JS for count up but when i reload the page time start from zero how could i save time like this
var clock;
$(document).ready(function() {
clock = $('.clock').FlipClock({
clockFace: 'DailyCounter'
});
});
Upvotes: 1
Views: 1882
Reputation: 12161
Here's one possible solution: Consider that it will not reset days value at the end of the month. But if you want you can set it to "autoStart: false" and "setInterval"...
$(document).ready(function() {
var date = new Date(),
days = date.getDate()*60*60*24,
hours = date.getHours()*60*60,
minutes = date.getMinutes()*60,
sec = date.getSeconds(),
clock = $('.clock').FlipClock({
clockFace: 'DailyCounter'
});
clock.setTime(days+hours+minutes+sec);
});
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="http://flipclockjs.com/_themes/flipclockjs/css/flipclock.css">
</head>
<body>
<div class="clock"></div>
<script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="http://flipclockjs.com/_themes/flipclockjs/js/flipclock/flipclock.js"></script>
</body>
</html>
Upvotes: 2