There is a great JavaScript library that does a great job of this, and is reduced to only 5.5KB.
http://momentjs.com/
It looks something like this:
moment().format('MMMM Do YYYY, h:mm:ss a'); // February 25th 2013, 9:54:04 am moment().subtract('days', 6).calendar(); // "last Tuesday at 9:53 AM"
You can also pass dates as a String with a format or as a Date object.
var date = new Date(); moment(date); // same as calling moment() with no args // Passing in a string date moment("12-25-1995", "MM-DD-YYYY");
There is also excellent support for languages ββother than English, such as Russian, Japanese, Arabic, Spanish and others.
Check documents .
knownasilya
source share