Skip to content

An extremely lightweight time difference JavaScript library.

Notifications You must be signed in to change notification settings

Benigntech/js-time-diff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Javascript Time Difference Library

An extremely lightweight time difference javascript library.

Install

// npm
npm i js-time-diff

// yarn
yarn add js-time-diff

Usages

Use in HTML
<script type="text/JavaScript" src="dist/time-diff.min.js" />

//use global variable TimeDiff
Or use in javascript
import TimeDiff from 'js-time-diff'; //es6

var TimeDiff = require('js-time-diff'); //es5

Example

TimeDiff('07-07-18', '07-10-18');
// output: 3 days ago

//the second parameter is the current date and time by default.
TimeDiff('07-07-18'); 
// output: 9 days ago

TimeDiff('Sun Jul 15 2018 16:01:07 GMT+0530');
// output: 31 seconds ago

TimeDiff('Sun Jul 15 2018 16:01:07 GMT+0530', 'Sun Jul 15 2018 16:02:55 GMT+0530');
// output: 2 minutes ago

TimeDiff('Sun Jul 15 2018 16:01:07 GMT+0530', new Date() );
// output: 2 days ago

Releases

No releases published

Packages

No packages published