我有两个值,一个来自“小时”数据,另一个来自“当前时间”,将比较它的小时并在发现匹配或相等时显示 请参阅下面的代码以获得更好的理解
export class HourlyForecast extends Component {
constructor(props) {
super(props);
this.state = {};
}
render() {
const { data } = this.props;
if(!data) return null;
const time = data.datetime
const time2 = time.slice(11,13)
console.log('HOURLY DATA', time2)
const time5 = moment.tz(this.props.timezone).format('HH:mm').slice(0,2)
console.log('TIME CURRENT', time5);
}
}
export default HourlyForecast
我想将每小时数据中的小时值与当前时间的小时值进行比较。怎么做?
请参阅上图作为参考。每小时数据的范围是从00到09,而当前时间是02。相对于当前时间,每小时数据必须从02开始显示。
答案 0 :(得分:0)
问题尚不清楚,尽管您可以尝试比较。
async function1(){
let hourData = await hourlyfunction()
let currentData await currentTimefunction()
return hourData==currentData
}