Human readable time distances for javascript
Switch branches/tags
Clone or download
Latest commit 68b1cdb Jul 25, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore switch to ava Oct 27, 2017
.travis.yml CI: Update tested Node.js versions Jul 25, 2018 Release 0.1.6 May 11, 2016 Cleanup package Aug 9, 2017 remove browser comment and update examples Oct 29, 2017
index.js fix indentation Oct 29, 2017
package.json Update urls to package.json Oct 29, 2017
test.js fix indentation Oct 29, 2017

Human Interval

Human readable interval parser for Javascript.

Heavily inspired by matthewmueller/date.

Example Usage

const humanInterval = require('human-interval');

setTimeout(() => {
  // Do something crazy!
}, humanInterval('three minutes'));

More sophisticated examples

Human Interval understands all of the following examples:

humanInterval('one minute');
humanInterval('1.5 minutes');
humanInterval('3 days and 4 hours');
humanInterval('3 days, 4 hours and 36 seconds');

The full list

Supported Units

Human Interval supports the following units

  • seconds
  • minutes
  • hours
  • days
  • weeks
  • months -- assumes 30 days
  • years -- assumes 365 days

Wordy Numbers

Human Interval supports numbers up to ten being written out in English. If you want to extend it, you can do so by adding more keys to the language map. Alternatively you could add support for alternative languages.

const humanInterval = require('human-interval');
humanInterval.languageMap['one-hundred'] = 100

// Adds support for the following:
humanInterval('one-hundred and fifty seconds') // returns 150000


The MIT License