JSFiddle - React, Tailwind, and code Playground

by Graham Fairweather

HTML

<script src="https://raw.github.com/timrwood/moment/2.0.0/min/moment.min.js"></script>

JavaScript

var start = moment([1990, 0, 1]);
var end = moment([1900, 0, 2]);

var diff = start.diff(end, "years", true);

console.log(Math.floor(diff) + " years and " + Math.floor(30 * ((12 * (diff % 1)) % 1)) + " days and " + Math.floor(12 * (diff % 1)) + " months");