8 def diff_time(timestamp, abstime=True):
13 diff = now - timestamp
16 # return the number of seconds as a difference from current time.
18 if diff < 60: # sec in min.
20 t_str = "%s sec ago" % int(math.ceil(t))
21 elif diff < 60*60: # sec in hour
23 t_str = "%s min ago" % int(math.ceil(t))
24 elif diff < 60*60*24: # sec in day
26 t_str = "%s hrs ago" % int(math.ceil(t))
27 elif diff < 60*60*24*14: # sec in week
29 t_str = "%s days ago" % int(math.ceil(t))
30 elif diff <= 60*60*24*30: # approx sec in month
32 t_str = "%s days ago" % int(math.ceil(t))
33 elif diff > 60*60*24*30: # approx sec in month
34 t = diff / (60*60*24*30)
35 t_str = "%s mnths ago" % int(t)