I noticed today that in my twitter app on WP7, the twits are shown and their times are listed. But, here is what I really liked:
If a twit was made in the last few seconds, the listbox item displays for eg. 5 secs ago.
If it was made in last few mintues, it shows for eg. 23 min ago.
Same way, shows the word today
If it was on any prior dates, it shows the actual date time.
This type of formatting would apply to any platform (Outlook does similar things). Has anyone written an extension method or a helper function that they can share to achieve this kind of output?
Thanks,
Pratik
Scott Mitchell had an article featured on the homepage of http://www.asp.net the other day which covered formatting dates.
The article was a pretty standard run through of the various formatting strings you can use but about two thirds in he discusses a custom method he has created to solve this kind of problem called
.ToRelativeDateString(). The implementation is included in the downloadable sample attached to the article: