Pretty dates
It is often useful to represent a datetime not as “2009-07-25 14:34:56” but as “one year ago”. web2py provides a utility function for this:
import datetime
d = datetime.datetime(2009, 7, 25, 14, 34, 56)
from gluon.tools import prettydate
pretty_d = prettydate(d, T)
The second argument (T) must be passed to allow internationalization for the output.