moment-js
by robhortn
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
JavaScript
// Calculate and print to the console the number of days between 1/1/2017 and the current date.
// Then print to the console the current date formatted to look something like 12/1/2017 6:30:15 pm.
// Feel free to use any public libraries as you see fit.
function getDaysFromDateTillNow(startDate) {
var duration = moment.duration(moment().diff(startDate));
var days = duration.asDays();
console.log(days);
}
function prettyPrintCurrentDate() {
var prettyPrinted = moment().format('MM/DD/YYYY, h:mm:ss a');
console.log(prettyPrinted);
}
getDaysFromDateTillNow(new Date('1/1/2017'));
prettyPrintCurrentDate();