Note that there are some explanatory texts on larger screens.

plurals
  1. POIssue in getting the Time of creation of a tweet
    text
    copied!<p>I'm using Tweetsharp library to display the latest 5 tweets posted by a user. I've created an app at dev/twitter and got the required tokens. I want to show the time lapsed since the tweet was posted. But the "tweet.CreatedDate" method from the Tweetsharp library is provides a time 5-6 hrs before the time of tweeting. </p> <pre><code> public DataSet GenerateTweetDataSet() { string time = ""; int hrs = 0, mins = 0; int days = 0; TwitterService service = new TwitterService(ConsumerKey, ConsumerSecret); service.AuthenticateWith(AccessToken, AccessTokenSecret); ListTweetsOnUserTimelineOptions tweetoptions = new ListTweetsOnUserTimelineOptions(); tweetoptions.Count = 5; tweetoptions.ScreenName = _twitter.ScreenName; var tweets = service.ListTweetsOnUserTimeline(tweetoptions); DataTable TweetsTable = new DataTable(); TweetsTable.Columns.Add("Text"); TweetsTable.Columns.Add("DateTime"); TweetsTable.Columns.Add("Id"); if (tweets != null) foreach (var tweet in tweets) { string UserName = tweet.User.ScreenName; string TweetText = tweet.Text; DateTime tweetDate = tweet.CreatedDate; DateTime currentDate = DateTime.Now; time = (currentDate - tweetDate).Days.ToString(); TimeSpan t1 = currentDate.Subtract(tweetDate); mins = (Int32)t1.TotalMinutes; hrs = (Int32)t1.TotalHours; days = (Int32)t1.TotalDays; if (mins &lt; 60) { time = mins + " mins ago"; } else if (mins &gt; 60 &amp;&amp; hrs &lt;= 24) { time = hrs + " hours ago"; } else if (hrs &gt; 24 &amp;&amp; days &lt; 365) { time = days + " days ago"; } else if (days &gt; 365) { time = "over a year ago"; } long id = tweet.Id; TweetsTable.Rows.Add(TweetText, time, id); } DataSet ds = new DataSet(); ds.Tables.Add(TweetsTable); return ds; } </code></pre> <p>Can someone please point where I'm going wrong or how to fix this issue. If not then, is there a better/simpler way to get the tweets? Any sample code without using any API library? Any help will be appreciated. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload