Highlight expired dates in input date

1

Is it possible to list dates, highlight those that are due?

To make it easier to locate them.

For example

2016-10-29
2016-10-01
2016-10-29
2016-10-29
2016-10-29
2016-10-29

That the date 2016-10-01 is highlighted in red

    
asked by pepemujica 18.10.2016 в 21:04
source

1 answer

1

What you should do basically is to compare the date to determine if it is less than the current one and if so, apply a css class with which you customize the styles.

function esMenorQueFecha(fecha1) {
  return fecha1 < new Date();
}

var fechaComoString = '2016-10-01';
var newDiv = document.createElement("div"); 
var newContent = document.createTextNode(date);
if(esMenorQueFecha(new Date(fechaComoString))) {
 newContent.className = 'menor';
}
newDiv.appendChild(newContent);

css

.menor {
  color: red;
}
    
answered by 18.10.2016 в 23:13