TimeAgo Function


/ Published in: ASP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. Function TimeAgo(dtField)
  2. days = DateDiff("d", dtField, Now)
  3. If days > 365 Then
  4. years = DateDiff("yyyy", dtField, Now)
  5. If years = 1 Then
  6. ago = "Expired " & years & " year ago"
  7. Else
  8. ago = "Expired " & years & " years ago"
  9. End If
  10. ElseIf days > 30 Then
  11. months = DateDiff("m", dtField, Now)
  12. If months = 1 Then
  13. ago = "Expired " & months & " month ago"
  14. Else
  15. ago = "Expired " & months & " months ago"
  16. End If
  17. Else
  18. ago = "Expired " & days & " days ago"
  19. End If
  20. TimeAgo = ago
  21. End Function

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.