asp.net mvc - Returning days/months since latest post -
i have in controller:
model.latestposts = db.tpgforumposts.select(v => v).orderbydescending(d => d.datecreated).take(5);
this gives me 5 latest posts.
i going display them on cshtml page.
is there easy way convert date days/months since today?
a cold hard truth jwilson posted 5 days ago cold hard fact jwilson posted 3 months ago
one option use jquery , timeago plugin: http://timeago.yarp.com/
your view need this:
<script src="jquery.min.js" type="text/javascript"></script> <script src="jquery.timeago.js" type="text/javascript"></script> <abbr class="timeago" title="2008-07-17t09:24:17z">july 17, 2008</abbr> jquery(document).ready(function() { jquery("abbr.timeago").timeago(); });
Comments
Post a Comment