Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Javascript module for outputting relative dates.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 COPYING
Octocat-spinner-32 README.md
Octocat-spinner-32 package.json
README.md

Javascript module for outputting relative dates. Tested platforms: Node, Firefox 3.6, Chromium 8.0

Install

npm install relative-date

Usage

On browsers:

<script src="relative-date.js"></script>
<script>
  assert( relativeDate(new Date()), 'just now' );
  assert( relativeDate(1299627946000), '12 minutes ago');
  assert( relativeDate(0), '41 years ago');
</script>

On a CommonJS compliant environment:

> var relativeDate = require('relative-date');
> relativeDate(new Date())
'just now'
> relativeDate(1299627946000)
'12 minutes ago'
> relativeDate(0)
'41 years ago'

Testing

node test/node.js || test/browser.html

Something went wrong with that request. Please try again.