Skip to content

Instantly share code, notes, and snippets.

@wgrrrr
Last active December 30, 2015 15:48
Show Gist options
  • Save wgrrrr/7850241 to your computer and use it in GitHub Desktop.
Save wgrrrr/7850241 to your computer and use it in GitHub Desktop.
C# ASP.NET MVC JavaScript relative TimeAgoInWords using jQuery Timeago plugin. Place the Helpers.cshtml file (or its contents) into your App_Code directory.
$(function() {
$("time.timeago").timeago();
});
@helper TimeAgoInWords(DateTime dateTime) {
<time class="timeago" datetime="@dateTime.ToString("yyyy-MM-ddTHH:mm:ssK")" title="@dateTime.ToString("f")">
@dateTime.ToString("f")
</time>
}
@Helpers.TimeAgoInWords(DateTime.Now)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment