Coder Social home page Coder Social logo

miteshtagadiya / react-timesago Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 489 KB

A component that takes a date as a prop and returns a time-span with live updating date.

License: MIT License

HTML 14.07% CSS 0.56% JavaScript 85.37%
react-timeago react-time-range react-times timesago-react time-spans

react-timesago's Introduction

React-TimesAgo

npm npm npm npm

React-TimesAgo is a component that takes a date as a prop and returns a time-span with live updating date.

Demo

React-TimesAgo

Installation

  1. Install React-TimesAgo as a dependency
# NPM
npm install react-timesago
  1. Import the react-timesago module
// ES6
import TimesAgo from "react-timesago";

Example

import TimesAgo from 'react-timesago';

render() {
<TimesAgo time={date} type="default" suffix="ago" /> // type default
<TimesAgo time={date} type="default" prefix="before" /> // type default
<TimesAgo time={date} type="facebook" /> // type facebook
}

Props

These are all of the available props (and their default values) for the <TimesAgo /> component.

{
    prefix: "",
    suffix: "ago",
    type: "default",
    time: new Date(1551788578911 * 1000)
}

Props Details

  • prefix - formatter prefix for date, ignored for type facebook.
  • suffix - formatter suffix for date, ignored for type facebook.
  • type - types for date format (facebook or default)
  • time - date.

react-timesago's People

Contributors

miteshtagadiya avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.