I have the following javascript:
const to = moment(item.to);
const toNextDay = to.add(1, 'days');
item.to is a string that has the following format:
"2020-06-30T00:00:00"
But is not adding the next day, that would be "2020-07-01T00:00:00"
This is the Function:
private getCurrentRecord(records: ConfigRecord[]) {
let result: string = null;
for (let index = records.length - 1; index >= 0; index--) {
const item = records[index];
if (item.from && item.to) {
const from = moment(item.from);
const to = moment(item.to).add(1, 'days');
const today = moment();
console.log(today.format());
if (from <= today && today < to) {
result = item.value;
break;
}
}
}
return result;
}