dd-get-age

1.0.0 • Public • Published

dd-get-age

Get age based on date of birth

Installation

$ npm install dd-get-age

Valid formats

'DD.MM.YYYY', 'DD-MM-YYYY', 'DD/MM/YYYY'
'YYYY.MM.DD', 'YYYY-MM-DD', 'YYYY/MM/DD'

Use

// CommonJS
const getAge = require('dd-get-age');

// ES6
import getAge from 'dd-get-age';
// Valid dates and formats
getAge('06.06.1997'); // returns 23
getAge('06-06-1997'); // returns 23
getAge('06/06/1997'); // returns 23
getAge('1997.06.06'); // returns 23
getAge('1997-06-06'); // returns 23
getAge('1997/06/06'); // returns 23

// Invalid dates and formats or whatever
getAge('32-06-1997'); // returns null
getAge('1997-06-32'); // returns null
getAge(19970606); // returns null
getAge(06061997); // returns null
getAge('abc'); // returns null
getAge([]); // returns null
getAge({}); // returns null
getAge('<Anything else>') // returns null

Readme

Keywords

Package Sidebar

Install

npm i dd-get-age

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

2.56 kB

Total Files

3

Last publish

Collaborators

  • daeltondias