Here is a small extension method over System.DateTime that gives its relative time readable for humans, such as:
- one minute ago
- 2 minutes ago
- one hour ago
- 3 hours ago
- 3 days ago
Check out this extension method over the DateTime structure using switch patterns.
💡
Don't forget to join our newsletter becoming a member
Bonus! Different solutions for the same problem
Surfing the web - I'm so old - I found two more solutions for the same problem.
Tell me in the comments section which one you like the best.
First Solution
Second Solution
❤️ Enjoy this article?
Forward to a friend and let them know.
Leave a comment with questions or improvements.