generate functionSat, 24 Dec 2022

checks 'Y-m-d H:s:i' if date is today, tomorrow, already passed or sometime in the future

function checkdate(date) { if (date.format('YYYY-MM-DD') == moment().format('YYYY-MM-DD')) { return 'today'; } if (date.isAfter(moment().format('YYYY-MM-DD'))) { return 'tomorrow'; } if (date.isBefore(moment().format('YYYY-MM-DD'))) { return 'in the past'; } return 'future'; }

Questions about programming?Chat with your personal AI assistant