有必要仅从数组中显示与当前日期相比最大的日期。结果,我显示了所有日期。
<body class="turrell">
<div class="container">
<div class="carton">
<div class="egg">
<div class="egg">
<div class="egg">
<div class="egg">
<div class="egg">
<!-- THE LIGHT -->
</div>
</div>
</div>
</div>
</div>
</div>
<h6 class="art-caption"><a href="http://www.guggenheim.org/new-york/exhibitions/past/exhibit/4819" target="_blank">Homage to <em>Aten Reign</em> by James Turrell</a></h6>
</div>
</body>
示例状态:
const states = States.select().exec()
var curr = new Date();
for (var i = 0; i < states.length; i++) {
var maxDate = Math.max(new Date(states[i]._props.state_date))
if (curr > maxDate) {
console.log(states[i]._props.state_date)
}
}
答案 0 :(得分:1)
尝试:
const states = States.select().exec()
var largest = null
for (var i = 0; i < states.length; i++) {
var currDate = new Date(states[i]._props.state_date))
if (!largest || currDate > largest) {
largest = currDate
}
}
console.log(largest)