A while ago, I was learning how to write a custom function in Google Docs Spreadsheet, even wrote a wiki page to note about input and output of custom function. I picked timeago function as an exercise.

I submitted the finished script to gallery, you could find it by searching timeago:

http://4.bp.blogspot.com/-d_GEU-_TPU8/T9lYasFsvQI/AAAAAAAADZc/uOHWTK1Rnpg/s1600/timeago+in+Google+Docs+Spreadsheet.png

Here is the test spreadsheet.

For the source code, I think you can view it in that test spreadsheet or after you install the script, not really sure. I lost my interest in writing custom function since I dont need any for practical uses.