Age.calculate()

Calculate an age based on date of birth.

Usage

Hover over inputs/exits for more info.

var Age = require('machinepack-age');


// Calculate an age based on date of birth.

Age.calculate({

dateOfBirth: '1991-04-24',

}).exec({

// An unexpected error occurred.

error: function (err) {

 

},

// Invalid date format supplied (expected yyyy-mm-dd or instance of Date).

invalidDateFormat: function () {

 

},

// OK.

success: function (result) {

 

},

});

Inputs

dateOfBirth required

A date of birth `Date` instance or string in yyyy-mm-dd format.

'1991-04-24'

Exits

error

An unexpected error occurred.

invalidDateFormat

Invalid date format supplied (expected yyyy-mm-dd or instance of Date).

success

OK.

23