I have two values, one from Hourly data and other from Current Time, where its hour is to be compared and display when found match or equal See below code for better understanding(我有两个值,一个来自“小时”数据,另一个来自“当前时间”,将比较它的小时并在找到匹配或相等时显示它。请参见下面的代码,以更好地理解)
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
I want to compare the hour value from hourly data with current time's hour value.(我想将每小时数据中的小时值与当前时间的小时值进行比较。)
How to do it?(怎么做?) See the above image for reference.(请参阅上图作为参考。) The Hourly data ranges from 00 to 09 whereas Current Time is 02. The Hourly data must display from 02 comparing with Current Time.(每小时数据的范围是从00到09,而当前时间是02。与当前时间相比,每小时数据必须从02开始显示。)
ask by Pranav translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…