i would like to format my date coming from firebase to 'dd/MM/yyyy' format using javascript. The date in firebase database, is as timestamp field. I need show on the fron end the date formatted as ISO 8601
Code for store the values:
function NewEPI(){
const [name, setName] = useState('');
const [date, setDate] = useState('');
const db = firebase.firestore();
return <div>
<Navbar/>
<div className='container-fluid title>
<div className='offset-lg-2 col-lg-8 text-center'>
<h1> Cadastre </h1>
<form>
<div className='row g-2'>
<div className='form-floating'>
<input onChange={(e) => setName(e.target.value)} type='text' className='form-control' id='floatingInput' placeholder='Your name'/>
</div>
</div>
<div className='col-md'>
<div className='form-floating>
<input onChange={(e) => setDate(e.target.value)} type='date' className='form-control' id='floatingInput' placeholder='Date'/>
<label htmlfor='floatingInput> Date </label>
</div>
</div>
</form>
</div>
</div>
</div>
}
Code that returns the list of values in table:
{
props.arrayEpis.map((epi) => {
return <tr key={epi.id} className='text-center'>
<td> {epi.name} </td>
<td> {epi.date} </td>
})
}