Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    May 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Twitter Feed IE bug

    Hi, I have a twitter feed on my website that works perfectly except for on Internet Explorer. When using Internet Explorer the date, instead of saying 15 days ago etc..., is instead saying: NaN days ago.

    Is there a quick fix to my code to solve this issue?

    Code:
        <script src="/js/twitter.js"></script>
        <script>
        $(document).ready(function() {
            // search the page for the .twitter class
            $( ".js_twitter" ).each(function() {
                // Retrieve data attributes with twitter info
                var twitter_username = $(this).attr("data-twitter-username");
    
                var twitter_tweet_count = $(this).attr("data-twitter-tweet-count");
                if(!twitter_tweet_count){
                    twitter_tweet_count = 5;
                }        
    
                var twitter_element = $(this).attr("data-twitter-element-id");
                if(!twitter_element){
                    twitter_element = $(this).attr("id");
                }
    
                // Function retrieves tweets
                twitter(
                    twitter_username,
                    twitter_element,
                    twitter_tweet_count
                );
            });
        });
        </script>
    Thanks in advance

  • #2
    New to the CF scene
    Join Date
    May 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Apologies, wrong code posted. Correct is below:

    Code:
    function twitter_time_since(datetime)
    {
        var tTime=new Date(datetime);
        var cTime=new Date();
        var sinceMin=Math.round((cTime-tTime)/60000);
        if(sinceMin==0)
        {
            var sinceSec=Math.round((cTime-tTime)/1000);
            if(sinceSec<10)
              var since='less than 10 seconds ago';
            else if(sinceSec<20)
              var since='less than 20 seconds ago';
            else
              var since='half a minute ago';
        }
        else if(sinceMin==1)
        {
            var sinceSec=Math.round((cTime-tTime)/1000);
            if(sinceSec==30)
              var since='half a minute ago';
            else if(sinceSec<60)
              var since='less than a minute ago';
            else
              var since='1 minute ago';
        }
        else if(sinceMin<45)
            var since=sinceMin+' minutes ago';
        else if(sinceMin>44 && sinceMin<60)
            var since='about 1 hour ago';
        else if(sinceMin<1440){
            var sinceHr=Math.round(sinceMin/60);
        if(sinceHr==1)
          var since='about 1 hour ago';
        else
          var since='about '+sinceHr+' hours ago';
        }
        else if(sinceMin>1439 && sinceMin<2880)
            var since='1 day ago';
        else
        {
            var sinceDay=Math.round(sinceMin/1440);
            var since=sinceDay+' days ago';
        }
        return since;
    };


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •