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

Popular posts from this blog

php - Magento - Deleted Base url key -

javascript - Tooltipster plugin not firing jquery function when button or any click even occur -

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -