Another short one from me today. I have been very busy with work and moving flat recently which means I haven’t been able to post as often as I’d like and as often as I’m suppose to give the rather simple rules of the postaweek 2011 challenge. I fell behind whilst away and haven’t been able to catch up. Sorry about that.
On to this post.
One of the things I needed to do for work was to display some dates in a more friendly and understandable way. Seen as it wasn’t imperative for the user to know the exact, to the second time of creation I decided I wanted to display them in a similar way to sites that display them like “a year ago” and “2 weeks ago”. After a quick google I couldn’t find exactly what I needed — I’m sure if I’d’ve continued my search something suitable would’ve been found but I thought it would be a quick interesting problem to solve.
I hope you find it useful, and if you have any ideas about improvements then please go ahead and post them in the comments section, I’d love to hear them.
I’ve behind thinking about rewriting it using the Date.prototype object but I’m not sure whether it would be worth it. If I do though I’ll make sure I post the code here for those that are interested.