STILL ON ANALYSIS
by Carl Angelo Nievarez
JavaScript
function formatDate(d) {
month = '' + (d.getMonth() + 1),
day = '' + d.getDate(),
year = d.getFullYear();
if (month.length < 2) month = '0' + month;
if (day.length < 2) day = '0' + day;
date = [month, day, year].join('/');
var hours = d.getHours();
var minutes = d.getMinutes();
var ampm = hours >= 12 ? 'PM' : 'AM';
hours = hours % 12;
hours = hours ? hours : 12; // the hour '0' should be '12'
minutes = minutes < 10 ? '0' + minutes : minutes;
var strTime = hours + ':' + minutes + ' ' + ampm;
return date + " " + strTime;
}
var a = new Date();
a.setDate(a.getDate());
var todaydate = formatDate(a);
var d = new Date('07/21/2017 8:30 AM');
d.setDate(d.getDate() - 3);
var yesterday = formatDate(d);
alert(todaydate + ' less than or equal to ' + yesterday);
if (todaydate >= yesterday) {
alert('OK PA');
} else {
alert('ALERT ALERT');
}