那里有任何可以为我转换的VB / Javascript专家吗?
Protected Function RelativeTime(ByVal dtTime As DateTime) As String
Dim timeDiff As TimeSpan = DateTime.Now.ToUniversalTime().Subtract(dtTime)
If timeDiff.TotalMinutes < 1 Then
Return "less than a minute ago."
ElseIf timeDiff.TotalMinutes < 2 Then
Return "about one minute ago"
ElseIf timeDiff.TotalMinutes < 60 Then
Return String.Format("about {0:N0} minutes ago", timeDiff.TotalMinutes)
ElseIf timeDiff.TotalHours < 2 Then
Return "about an hour ago"
ElseIf timeDiff.TotalHours < 12 Then
Return String.Format("about {0:N0} hours ago", timeDiff.TotalHours)
ElseIf timeDiff.TotalDays < 365 Then
Return dtTime.ToString("MMM d")
Else
Return dtTime.ToString("MMM d, yyyy")
End If
End Function