vb.net - Convert VB function to Javascript -
any vb/javascript guru out there can convert me?
protected function relativetime(byval dttime datetime) string dim timediff timespan = datetime.now.touniversaltime().subtract(dttime) if timediff.totalminutes < 1 return "less minute ago." elseif timediff.totalminutes < 2 return "about 1 minute ago" elseif timediff.totalminutes < 60 return string.format("about {0:n0} minutes ago", timediff.totalminutes) elseif timediff.totalhours < 2 return "about hour ago" elseif timediff.totalhours < 12 return string.format("about {0:n0} hours ago", timediff.totalhours) elseif timediff.totaldays < 365 return dttime.tostring("mmm d") else return dttime.tostring("mmm d, yyyy") end if end function
there plenty of answers on address this. search "javascript time ago".
Comments
Post a Comment