Skip to content

TapasFE/tapas-timeago

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

timeago

Format timestamps in a readable way.

Usage

const formatTime = require('tapas-timeago');

// Optionally import locales
require('tapas-timeago/locales/zh_CN.js');

// Or set locales directly
formatTime.strings = {
  justNow: 'Just now',
  seconds: 'A few seconds ago',
  minutes: ['A minute ago', '{} minutes ago'],
  hours: ['An hour ago', '{} hours ago'],
  days: ['A day ago', '{} days ago'],
  weeks: ['A week ago', '{} weeks ago'],
  months: ['A month ago', '{} months ago'],
  years: ['A year ago', '{} years ago'],
  longAgo: 'Long long ago',
};

console.log(formatTime('2017-01-16T09:17:13.412Z'))

About

Format timestamps in a readable way.

Resources

Stars

Watchers

Forks

Packages

No packages published