moment.js date in Django template
<p>I want to display the date of the relevant text (for example, 3 days ago) using the moment.js. But my code does not work.</p>

<p>My code, but it does not work:</p>

<pre><code>&lt;div class="base"&gt;
    &lt;script type="text/javascript"&gt;
        var time = {{ obj.pub_date|date:'Ymd' }};
        moment(time, "YYYYMMDD").fromNow();
    &lt;/script&gt;
    &lt;p&gt;{{ obj.text }}&lt;/p&gt;
&lt;/div&gt;
</code></pre>

<p>You are not assigning whatever is returned from your .fromNow() call to a variable, or doing anything with it.</p>

javascript python django momentjs