Convert Seconds Into Human-readable Durations - Timer2

Convert Seconds Into Human-readable Durations - Timer2
File Size: 106 KB
Views Total:
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

Timer2 is a small and fast duration formatter that converts user-provided seconds into human-readable durations like , , and so on.

How to use it:

1. Place the minified version of the timer2 plugin after jQuery but before the </body> tag.

<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" 
        integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" 
        crossorigin="anonymous">
</script>
<script src="./dist/timer2.min.js"></script>

2. Wrap the durations into container elements.

<div class='timer2'>86300</div>
<span class='timer2'>86490</span>
...

3. Call the function to enable the duration formatter.

$(function(){
  $('.timer2').timer2();
});

4. The plugin also supports input filed where the user can modify the days, hours, minutes, and seconds.

<input type="text" name="FirstName" class="timer2" value="86400">

5. Slightly adjust the styles of the durations.

.timer2-inside {
  display: inline;
  width: 20px;
  margin: 0 2px;
}  

This awesome jQuery plugin is developed by moneyfly. For more Advanced Usages, please check the demo page or visit the official website.