Getting human readable relative times and dates from a unix timestamp?
问题 Starting with a unix timestamp like 1290529723, how would I (assuming gmt) get the information on whether it is: today (if so, what time) in the last seven days (if so, which day ... mon, tues etc?) older than a week (if so, how to output in dd/mm/yy format?) I need this for a list of messages like the iPhone's Mail app, where date/times are shown relative to the current date and time, like so: 15:45 Yesterday Sunday Saturday 10/10/10 etc 回答1: It takes a bit of fiddling to get a solution that