You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
586 B

  1. import { injectIntl, FormattedRelative } from 'react-intl';
  2. import PropTypes from 'prop-types';
  3. const RelativeTimestamp = ({ intl, timestamp }) => {
  4. const date = new Date(timestamp);
  5. return (
  6. <time dateTime={timestamp} title={intl.formatDate(date, { hour12: false, year: 'numeric', month: 'short', day: '2-digit', hour: '2-digit', minute: '2-digit' })}>
  7. <FormattedRelative value={date} />
  8. </time>
  9. );
  10. };
  11. RelativeTimestamp.propTypes = {
  12. intl: PropTypes.object.isRequired,
  13. timestamp: PropTypes.string.isRequired
  14. };
  15. export default injectIntl(RelativeTimestamp);