-1

Possible Duplicate:
Javascript library for human-friendly relative date formatting

How to show 2days ago, 3 months ago instead of time and date in Jquery?

Community
  • 1
  • 1

2 Answers2

2

You need to use a plugin to format the date in a human-readable way.

One such plugin is http://timeago.yarp.com/.

eagleflo
  • 1,184
  • 9
  • 14
  • Plugins are not the only way of introducing additional functionality. It can be done entirely independently if jQuery, and even where the OP is already using jQuery, it is doubtful that a plugin is more advantageous than other methods. – RobG Apr 16 '12 at 12:36
  • Sure, plugins are just one option. But I favor code reuse instead of falling for the [Not Invented Here](http://en.wikipedia.org/wiki/Not_invented_here) syndrome. As an added bonus, in this case the timeago plugin contains numerous locales that have been translated by contributors (see https://github.com/rmm5t/jquery-timeago/tree/master/locales). – eagleflo Apr 16 '12 at 12:42
  • Plugins are not the only type of reuse, nor do they necessarily promote it. Anyone can write a "plugin", it need not be reused for anything. Interesting that language packs are called "locales". Does my preferred language change based on where I am, or some other criterion? – RobG Apr 16 '12 at 13:09
1

Pretty Date Plugin is one of the easiest I know. For a native solutions, this answer by Alex is very good.

Community
  • 1
  • 1
Starx
  • 77,474
  • 47
  • 185
  • 261