我用一些時間實用程序方法得到了一個類。現在我需要補充說明一個方法:解析日期時間實例
public static string LastUpdated(DateTime date)
{
string result = string.Empty;
//check if date is sometime "today" and display it in the form "today, 2 PM"
result = "today, " + date.ToString("t");
//check if date is sometime "yesterday" and display it in the form "yesterday, 10 AM"
result = "yesterday, " + date.ToString("t");
//check if the day is before yesterday and display it in the form "2 days ago"
result = ... etc;
return result;
}
任何想法?
看起來像你在正確的軌道上。有什麼特別讓你着迷? – 2011-04-29 17:37:22