maurogestoso
10/16/2017 - 12:16 PM

medium-momentjs-display.js

// parse delivery date provided by the courier
const deliveryDate = moment('2017-10-20 09:30', 'YYYY-MM-DD HH:mm');
console.log(deliveryDate.toString());  // Fri Oct 20 2017 09:30:00 GMT+0100

// calculate relative time from now to delivery date
const timeToWait = moment().to(deliveryDate);
console.log(timeToWait);  // in 4 days