Skip to content

Instantly share code, notes, and snippets.

@ericf
Created November 11, 2015 07:14
Show Gist options
  • Select an option

  • Save ericf/7d14714f7dc1e7c4328b to your computer and use it in GitHub Desktop.

Select an option

Save ericf/7d14714f7dc1e7c4328b to your computer and use it in GitHub Desktop.

Revisions

  1. ericf renamed this gist Nov 11, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. ericf created this gist Nov 11, 2015.
    28 changes: 28 additions & 0 deletions UPGRADE.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    import React from 'react';
    import {
    injectIntl,
    FormattedRelative,
    } from 'react-intl';

    const TimeAgo = ({date, intl}) => {
    let year = intl.formatDate(date, {year: 'numeric'});
    let month = intl.formatDate(date, {month: '2-digit'});
    let day = intl.formatDate(date, {day: '2-digit'});

    let formattedDate = intl.formatDate(date, {
    year : 'long',
    month: 'numeric',
    day : 'numeric'
    });

    return (
    <time
    datetime={`${year}-${month}-${day}`}
    title={formattedDate}
    >
    <FormattedRelative value={date} />
    </time>
    );
    };

    export default injectIntl(TimeAgo);