Skip to content
Plugin for momentjs to round time in dates.
JavaScript
Find file
Latest commit 1d20ce5 Sep 15, 2015 @WebDevTmas Merge pull request #2 from guru-digital/master
Fix issue if Array has had its prototype extended
Failed to load latest commit information.
dist First commit Jul 11, 2015
src Fix issue if Array has had its prototype extended Sep 10, 2015
test First commit Jul 11, 2015
.gitignore First commit Jul 11, 2015
LICENSE First commit Jul 11, 2015
README.md Update README.md Jul 11, 2015
bower.json Fixed repository in package.json Jul 11, 2015
gulpfile.js First commit Jul 11, 2015
package.json Fixed repository in package.json Jul 11, 2015

README.md

moment-round

This is a plugin for moment.js and will round date/time to a given interval.

Examples

var m = new moment(); // 2015-06-18 15:30:19
moment.round(5, 'seconds'); // 2015-06-18 15:30:20
moment.ceil(3, 'minutes'); // 2015-06-18 15:33:00
moment.floor(16, 'hours'); // 2015-06-18 00:00:00
moment.ceil(21, 'hours'); // 2015-06-18 21:00:00
moment.ceil(20, 'hours'); // 2015-06-19 00:00:00

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.

Something went wrong with that request. Please try again.