Javascript. Pretty date with months and years
<p>I got the below script to convert dates into pretty dates. It works perfectly
fine but only to a level of weeks. I need it to work fine for months and perhaps years to.</p>

<p>How can I modify this code to work?</p>

<pre><code>function prettyDate(time) {

    var date = new Date((time || "").replace(/-/g,"/").replace(/[TZ]/g," ")),
        diff = (((new Date()).getTime() - date.getTime()) / 1000),
        day_diff = Math.floor(diff / 86400);

    if ( isNaN(day_diff) || day_diff &lt; 0 || day_diff &gt;= 31 ){

        return;

        }

    return day_diff == 0 &amp;&amp; (
            diff &lt; 60 &amp;&amp; "just now" ||
            diff &lt; 120 &amp;&amp; "1 minute ago" ||
            diff &lt; 3600 &amp;&amp; Math.floor( diff / 60 ) + " minutes ago" ||
            diff &lt; 7200 &amp;&amp; "1 hour ago" ||
            diff &lt; 86400 &amp;&amp; Math.floor( diff / 3600 ) + " hours ago") ||
        day_diff == 1 &amp;&amp; "Yesterday" ||
        day_diff &lt; 7 &amp;&amp; day_diff + " days ago" ||
        day_diff &lt; 31 &amp;&amp; Math.ceil( day_diff / 7 ) + " weeks ago";
}
</code></pre>
