Guest User

Untitled

a guest
Apr 20th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. A method to format old JavaScript dates in a "pretty" way. For example "2008-01-28T20:24:17Z" becomes "2 hours ago". Also include a .prettyDate() jQuery plugin, for convenience. Here's some more examples:
  2.  
  3. prettyDate("2008-01-28T20:24:17Z") // => "2 hours ago"
  4. prettyDate("2008-01-27T22:24:17Z") // => "Yesterday"
  5. prettyDate("2008-01-26T22:24:17Z") // => "2 days ago"
  6. prettyDate("2008-01-14T22:24:17Z") // => "2 weeks ago"
  7. prettyDate("2007-12-15T22:24:17Z") // => undefined
Add Comment
Please, Sign In to add comment