melvinsembrano / date-diff

Minimalized Javascript Dates arithmetic extension
MIT License
32 stars 7 forks source link

Build Status npm version

DateDiff

DateDiff is a minimalized javascript date arithmetic extension.

It works perfectly with easy-date

Installation

Node.js npm install date-diff

Bower bower install date-diff

Download the latest

Usage

Node.js

var DateDiff = require('date-diff');

In Browser

<script src="https://github.com/melvinsembrano/date-diff/raw/master/date-diff.js"></script>

Quickstart usage:

var date1 = new Date(2015, 11, 1); // 2015-12-1
var date2 = new Date(2014, 0, 1); // 2014-01-1

var diff = new DateDiff(date1, date2);

diff.years(); // ===> 1.9
diff.months(); // ===> 23
diff.days(); // ===> 699
diff.weeks(); // ===> 99.9
diff.hours(); // ===> 16776
diff.minutes(); // ===> 1006560
diff.seconds(); // ===> 60393600

Contributing to DateDiff

Copyright

Copyright (c) 2015 Melvin Sembrano. See LICENSE for further details