Create the below logic:
Convert your time to seconds, get the diff ( delta ) from current file :
% it by 3600*365
- if the
result > 0
then display year(s) ago
else % it by 3600 * 30
- if the
result > 0
then display month(s) ago
else % it by 3600 * 7
- if the
result > 0
then display week(s) ago
else % it by 3600
- if the
result > 0
then display day(s) ago
else % it by 3600 / 24
- if the
result > 0
then display hour(s) ago
else % it by 60
,
- if the
result > 0
then display minute(s) ago
NOTE: % means mod (modulus operation)