August 2017
Beginner
374 pages
10h 41m
English
This component will actually be quite simple, but it still makes sense to make a separate component for it, because the code will be re-used multiple times in other components. Furthermore, if we want to change the date/time format later, we can simply change it once in the Timestamp component, and it will be consistent everywhere.
Create a src/components/Timestamp.jsx file with the following contents:
import React from 'react'
const Timestamp = ({ data }) => {
const d = new Date(data)
return <span>{d.toUTCString()}</span>
}
export default Timestamp
Read now
Unlock full access