How can I convert a timestamp to a user-friendly time string
        Posted  
        
            by Steve Neal
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Steve Neal
        
        
        
        Published on 2010-04-22T20:01:40Z
        Indexed on 
            2010/04/22
            20:03 UTC
        
        
        Read the original article
        Hit count: 306
        
I want to be able to present "today" and "yesterday" for recent dates in my application. I've got a date formatter in use currently to show dates (retrieved from data records) and will keep using this for anything more than a couple of days old. I just really like the way the SMS app in the iPhone shows dates for recent messages and would like to emulate this.
The time-stamps that I have to work with are generated on a server that the phone downloads the data records from. All times are therefore generated at UTC (i.e. GMT) time.
I've been fiddling about with this for a while the solutions I've devised just seem horribly long-winded.
Can anyone suggest how to implement a method that could do this?
Cheers - Steve.
© Stack Overflow or respective owner