title: Convert VB function to Javascript
body: <p>Any VB/Javascript guru out there that can convert this for me?</p>
  
  <pre><code>Protected Function RelativeTime(ByVal dtTime As DateTime) As String
          Dim timeDiff As TimeSpan = DateTime.Now.ToUniversalTime().Subtract(dtTime)
  
          If timeDiff.TotalMinutes &lt; 1 Then
              Return "less than a minute ago."
          ElseIf timeDiff.TotalMinutes &lt; 2 Then
              Return "about one minute ago"
          ElseIf timeDiff.TotalMinutes &lt; 60 Then
              Return String.Format("about {0:N0} minutes ago", timeDiff.TotalMinutes)
          ElseIf timeDiff.TotalHours &lt; 2 Then
              Return "about an hour ago"
          ElseIf timeDiff.TotalHours &lt; 12 Then
              Return String.Format("about {0:N0} hours ago", timeDiff.TotalHours)
          ElseIf timeDiff.TotalDays &lt; 365 Then
              Return dtTime.ToString("MMM d")
          Else
              Return dtTime.ToString("MMM d, yyyy")
          End If
      End Function
  </code></pre>