Giter Site home page Giter Site logo

time-ago's Introduction

timeago

Simple timeago function takes same params as 'new Date(...)'

var ta = require('./time-ago.js')();  // node.js
var ta = timeago();					// browser

###ta.ago(..., [short])

ta.ago(new Date()-1000);  =>  "1 second ago"
ta.ago(new Date()-2000);  =>  "2 seconds ago"

ta.ago(1);  =>  "44 years ago"

// takes twitter's created_at date format, in your timezone
ta.ago('Sun Jun 28 19:44:05 +0000 2013'); => "2 days ago"

// and UTC
ta.ago('1997-07-16T19:20+01:00'); => "16 years ago"

// with optional short parameter
ta.ago(new Date()-1000, true);  =>  "1s"
ta.ago(new Date()-1000 * 60, true); => "1m"
ta.ago(new Date()-1000 * 60 * 60, true); => "1h"

###ta.today()

ta.today() function shows Day, Month, Date, Yr    
 ==> 'Monday, June 1, 1970'    

###ta.timefriendly('x period')

ta.timefriendly('1 hour')  // convert to ms: seconds, minutes, hours, days, weeks, months, years
 ==> 3600000

 ta.timefriendly('1 hour')  // convert to ms: seconds, minutes, hours, days, weeks, months, years
 ==> 3600000

###ta.mintoread(text, [altcmt, wpm]) Cool Medium like 'x min to read' feature

ta.mintoread('six hundred words of text')  // calculate based on 200 wpm reading speed
 ==> "3 min to read"

ta.mintoread('six hundred words of text', ' minutes to finish')  // optional alternate comment
 ==> "3 minutes to finish"

ta.mintoread('six hundred words of text', null, 300)  // alternate wpm
 ==> "2 min to read"

time-ago's People

Contributors

limero avatar cktang88 avatar sylvainbaronnet avatar digplan 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.