Is there a way to parse a relative date using Moment.js?

Just found chrono wile looking to see if NLP had already been implemented in momentjs. It looks like it handles parsing NLP to a date, which can be used to create a momentjs date.

Simply pass a string to function chrono.parseDate or chrono.parse.

> var chrono = require('chrono-node')

> chrono.parseDate('An appointment on Sep 12-13') 
Fri Sep 12 2014 12:00:00 GMT-0500 (CDT)

And a quick example showing how that would work

Code

const moment = require('moment')
const chrono = require('chrono-node')

let now = moment()
console.log(now)
let yrsAgo = chrono.parseDate("19 years ago")
console.log(yrsAgo)
let yrsAgoMoment = moment(yrsAgo)
console.log(yrsAgoMoment)

Output

$node test.js
moment("2017-06-30T08:29:20.938")
1998-06-30T17:00:00.000Z
moment("1998-06-30T12:00:00.000")

The only way of doing this is moment().sub(19, 'years');

What you are asking imply a Natural language processing which is whole computer science field.