moment-round
This is a plugin for moment.js and will round date/time to a given interval.
Examples
var m = new moment();
moment.round(5, 'seconds');
moment.ceil(3, 'minutes');
moment.floor(16, 'hours');
moment.ceil(21, 'hours');
moment.ceil(20, 'hours');
Possible values to round to are hours
, minutes
, seconds
Installation
Browser
<script src="moment.js"></script>
<script src="moment-round.js"></script>
Node /NPM
npm install moment-round --save-dev
And then require
it:
var moment = require('moment');
require('moment-round');
Bower
bower install moment-round
Running tests
gulp test
License
moment-round is LICENSED.