I am wanting to show some different data in my JavaScript app based on a Due Date
being past due
, in the future
, or due today
The code below works pretty good for showing if the Due Date
is in the future or past due from today's date.
It does not work for showing if the due date is set for today's date though so I could use some help getting that part to work please?
http://jsfiddle.net/jasondavis/sfj691st/
// Today's Date
var todayDate = new Date();
// Future Due Date
var futureDueDate = new Date("08/07/2015");
// Past Due Date
var pastDueDate = new Date("03/29/2015");
// Due Date Due Today!
var dueDateToday = new Date("05/27/2015");
// selected dueDate is in the future
if (futureDueDate < todayDate) {
alert('Due date is past due from todays date!');
}else if (futureDueDate == todayDate) {
alert('Task Due date is due today!');
}else{
alert('Due date is in the future from todays date!');
}
// selected dueDate is in the past
if (pastDueDate < todayDate) {
alert('Due date is past due from todays date!');
}else if (pastDueDate == todayDate) {
alert('Task Due date is due today!');
}else{
alert('Due date is in the future from todays date!');
}
// selected dueDate is in the past
if (dueDateToday < todayDate) {
alert('Due date is past due from todays date!');
}else if (dueDateToday == todayDate) {
alert('Task Due date is due today!');
}else{
alert('Due date is in the future from todays date!');
}
The end goal is to take a Due Date
and Today's Date
and change the color of my DateTime relative time string of text to show red text for due today and past due Due Dates. SHow green text for Due Dates set in the future.
Just like my images below:
Show Green Text if the Due Date is a date in the Future from today
Show red text if the Due Date is PAST DUE or DUE TODAY