I'm using react-datetime to render a calendar to user for date/time selection. How can I get the parse the value stored in state and turn it into a readable date so I can render that elsewhere in my UI.
I sent date in a post request and the value looks like: 2018-10-26T18:15:47.608Z. When I try to render that time in a table it gets stripped to this value 1540577747608. I want to display the zulu time for now.
this.state = {
date: new Date()
}
dateChange = date => this.setState({ date });
render() {
return (
<div>
<label>Choose a start date/time:</label>
<Datetime
onChange={this.dateChange}
value={this.state.date}
input={false}
isValidDate={validDate}
open={true}
utc={false}
onClickDay={value => alert("day" + value + "clicked")}
/>
</div>
</div>
In a different component where I want to render the date,
the value is being retrieved from an api call and being stored
formatDate: response.data.data.date
Then, I'm rendering in a table: <td key={schedule.formatDate}>{schedule.formatDate}</td>