The following code is inside return of render function
this.props.investment.selectedInvestor.rounds.map((item,index)=>{
if(item.type.toLowerCase()==this.state.securityType.toLowerCase())
{
return(
<tr onClick={()=>this.showRoundDetails(true,item)}>
<td>
<strong>{item.round_name}</strong><br/>
<span>{item.close_date}</span>
</td>
<td>{item.security_type}</td>
<td>{item.sharing_plan}</td>
<td>{item.investments[0].status}</td>
<td>{item.rate}</td>
<td>{item.frequency}</td>
<td>{item.investments[0].current_amount}</td>
</tr>
)
}
}
I want to convert {item.close_date} to another format i.e use this function toLocaleDateString()
I tried declaring another variable outside return and then convert the date but still could not solve it
item.close_date? Are you OK with using external libraries?item.close_datais aDate objectthen you can use that method directly like this:<span>{item.close_date.toLocaleDateString()}</span>