I have created a component using ReactJS where the information is received via json sent from the back-end.
componentDidMount() {
ObjectService.getObjects().then((response) => {
this.setState({objects : response.data});
});
I use componentDidMount for parsing the data.
I then render the component as
render() {
return (
<div>
{
this.state.objects.map(
objects =>
<div className="objects">
<div className="object-wrapper">
<p>Owner: {objects.author}</p>
<p>Created: {objects.time_created}</p>
<p>Updated: {objects.time_updated}</p>
</div>
</div>
)
}
</div>
);
The above works fine but my issue is that objects.time_created shows time as 1617145200000. (I believe this is epoch time?!) How do I show this in human readable format? E.g. Tuesday, 30 March 2021 23:00:00
The solution was what @rafaat-dev mentioned below, I just used:
<p>Created: {new Date(objects.time_created).toUTCString()}</p>
Instead of:
<p>Created: {objects.time_created}</p>