title: how to convert date and time to timeago format in jquery
body: <p>I am trying to display facebook newsfeed and displaying them on mobile web app. It is working fine but the problem is that it does not display time in timeago format(i.e. 2 days ago) on mobile web browser, on the other hand it does display properly on desktop. The format of the date and time is 2011-09-13T11:28:19+0000.</p>
  
  <p>on mobile it displays NaN years ago.</p>
  
  <p>here is my code for timeago function</p>
  
  <pre><code>timeAgo('2011-09-13T11:28:19+0000');
  function timeAgo(date_time) {                   
                  //to get unix timestamp
                  var currentDate = Math.round(+new Date()/1000);
                  var tweetDate = Math.round(+new Date(date_time)/1000); 
                  //alert(tweetDate);
                  var diffTime = currentDate - tweetDate;
                  //alert(diffTime);
                  if (diffTime &lt; 59) return 'less than a minute ago';
                  else if(diffTime &gt; 59 &amp;&amp; diffTime &lt; 120) return 'about a minute ago';
                  else if(diffTime &gt;= 121 &amp;&amp; diffTime &lt;= 3600) return (parseInt(diffTime / 60)).toString() + ' minutes ago';
                  else if(diffTime &gt; 3600 &amp;&amp; diffTime &lt; 7200) return '1 hour ago';
                  else if(diffTime &gt; 7200 &amp;&amp; diffTime &lt; 86400) return (parseInt(diffTime / 3600)).toString() + ' hours ago';
                  else if(diffTime &gt; 86400 &amp;&amp; diffTime &lt; 172800) return '1 day ago';
                  else if(diffTime &gt; 172800 &amp;&amp; diffTime &lt; 604800) return (parseInt(diffTime / 86400)).toString() + ' days ago';
                  else if(diffTime &gt; 604800 &amp;&amp; diffTime &lt; 12089600) return '1 week ago';
                  else if(diffTime &gt; 12089600 &amp;&amp; diffTime &lt; 2630880) return (parseInt(diffTime / 604800)).toString() + ' weeks ago';
                  else if(diffTime &gt; 2630880 &amp;&amp; diffTime &lt; 5261760) return '1 month ago';
                  else if(diffTime &gt; 5261760 &amp;&amp; diffTime &lt; 31570560) return (parseInt(diffTime / 2630880)).toString() + ' months ago';
                  else if(diffTime &gt; 31570560 &amp;&amp; diffTime &lt; 63141120) return '1 year ago';
                  else return (parseInt(diffTime / 31570560)).toString() + ' years ago';
              }
  </code></pre>
  
  <p>How can I solve this problem?</p>