mercredi 5 août 2015

Moment.js display hour time ago with minutes


Is there a way to display hours with minutes? ex: 2 hours 40 minutes ago.

Right now it just displays 2 hours ago

Here is a fiddle

<script src="http://ift.tt/t0Y3fx"></script>
<script src="/js/moment.js"></script>
<script>
  $(document).ready(function(){
    var then = $('#then'),
        date = moment(new Date(then.attr('data-date'))),
        update = function(){
                   then.html(date.fromNow());
                 };

    update();
    setInterval(update, 60000);
  });
</script>



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire