Last active
December 14, 2015 15:09
-
-
Save timrwood/5105451 to your computer and use it in GitHub Desktop.
Moment.js Twitter compliant feed display.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
moment.fn.twitter = function () { | |
var diff = moment().diff(this, 'seconds'); | |
return diff < 60 ? diff + 's' : | |
diff < 3600 ? ~~(diff / 60) + 'm' : | |
diff < 86400 ? ~~(diff / 3600) + 'h' : this.format('D MMM'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment