I am facing an issue in react js. I want to match alltime
with my start_time
but it is not matching with start_time. What is the mistake?
rest api
"appointments": [
{
"id": "23",
"start_date": "2020-05-13 16:00:00",
"end_date": "2020-05-13 16:30:00",
"cust_full_name": "CodupCustomer",
"full_name": "Test staff 2",
all time data:
[Wed May 13 2020 19:00:00 GMT+0500 (Pakistan Standard Time),
Wed May 13 2020 19:30:00 GMT+0500 (Pakistan Standard Time),
Wed May 13 2020 20:00:00 GMT+0500 (Pakistan Standard Time)]
fetch data
componentDidMount() {
axios.get(`http://localhost/v1/appointments`)
.then(res => {
const appointmentdata = res.data;
this.setState({
appointmentdata :appointmentdata.appointments
});
})
}
My component
<div class="row">
{this.state.appointmentdata && this.state.appointmentdata.length
? this.state.appointmentdata
var alltime = [prevDate,nextDate,firstDate,secDate,thirDate];
for(var i=0;i<alltime.length; i++){
const date = new Date(start_date);
if(date.toString() == alltime[i].toString()){
return (
<div class="w-name">
{full_name}
<p>{cust_full_name}</p>
</div>
)
}
else {
// console.log("cust",cust_full_name);
return( <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 col-3 without-name">
<p>hassan</p>
</div> )
}
}
}
)
: null}
console.log
start Wed May 13 2020 16:00:00 GMT+0500 (Pakistan Standard Time)
alltime Wed May 13 2020 19:00:00 GMT+0500 (Pakistan Standard Time)
start Wed May 13 2020 15:30:00 GMT+0500 (Pakistan Standard Time)
alltime Wed May 13 2020 19:00:00 GMT+0500 (Pakistan Standard Time)
start Wed May 13 2020 19:00:00 GMT+0500 (Pakistan Standard Time)
alltime Wed May 13 2020 19:00:00 GMT+0500 (Pakistan Standard Time)
start Wed May 13 2020 14:30:00 GMT+0500 (Pakistan Standard Time)
alltime Wed May 13 2020 19:00:00 GMT+0500 (Pakistan Standard Time)
I want to match alltime
with my start_time