Closed SWS-5007 closed 1 year ago
Hi. Libraries like date-fns have some useful utility functions for parsing and formatting dates. Please check codebase below.
date-fns
import React from 'react' import { parseISO, formatDistanceToNow } from 'date-fns' export const TimeAgo = ({ timestamp }) => { let timeAgo = '' if (timestamp) { const date = parseISO(timestamp) const timePeriod = formatDistanceToNow(date) timeAgo = `${timePeriod} ago` } return ( <span title={timestamp}> <i>{timeAgo}</i> </span> ) }
Please give me great feedback. Thanks!
Hi. Libraries like
date-fns
have some useful utility functions for parsing and formatting dates. Please check codebase below.Please give me great feedback. Thanks!