Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
css
i18n
README.md
index.html
jquery.niceDate.js
jquery.niceDate.min.js

README.md

jquery.niceDate plugin

It is a plugin to make dates more human readable. 12.12.2012 15:30 will become relative to 3 days ago. It supports i18n, currently english and sloven languages are supported. In the i18n folder is the demo for sloven language, so you can use the same schema to add another language.

Usage

The config options:

OptionDefault settingUsage
nowDateObjectnew Date()The current date object
makeTimestampfunctionthe function which takes text and return a JS Date object.
pattern/([0-3]?[0-9]).([0|1]?[0-9]).(\d{4})\s?(\d{2})?:?(\d{2})?$/How to parse the date
patternOrder[ 3, 2, 1, 4, 5 ]Date object parameters order
dayOnlyfalseIf true, minutes or hours wont be shown. 20 minutes after will become today
hoverShowtrueIf true on hover the original date will be shown
autoUpdateInterval60000Interval in milliseconds to update text. If 0 no update will be done.
monthMessages...See i18n
dayMessages...See i18n
hourMessages...See i18n
minMessages...See i18n

The standart usage would be:

$('.date').niceDate();
$('.date').niceDate({autoUpdateInterval: 0}); // no auto update

To manually update the text you can use the data object:

$('.date).each(function(){
	$(this).data('plugin_niceDate').update();
});

i18n

To be written.

Changelog

  • v0.2 Added auto update. Rewritten the whole plugin after jquery plugin boilerplate. Added manual update function.
  • v0.1 Freshly created

Demo available on http://maraz.org/demo/jquery-niceDate/ or the index.html file.