This project has moved and is read-only. For the latest updates, please go here.

How to get Twitter server time?

Jan 25, 2014 at 3:38 AM
I would like to calculate the exact elapsed time, in seconds, of a tweet. I'm using "createdat.tolocaltime" and my server current time, but for even more precision, I wish to calculate the offset with Twitter server time. How do I get Twitter server time ?

Jan 25, 2014 at 10:36 PM

TwitterContext has a ResponseHeaders property that populates after every query with the headers of Twitter's response. You can get the server date with this expression:
Jan 26, 2014 at 2:12 AM
Thanks Joe!

I also found twitterCtx.TwitterDate does the trick. For anyone interested, elapsed time can be calculated this way:
    Dim lTwitterServerTime As DateTime
    Dim lTimeOfTweet As DateTime
    Dim lElapsedTime As TimeSpan
    Dim lElapsedDisplay As String

     lTimeOfTweet = tweet.CreatedAt
     lTwitterServerTime = twitterCtx.TwitterDate
     lElapsedTime = lTwitterServerTime.Subtract(lTimeOfTweet)
     lElapsedDisplay = lElapsedTime.TotalSeconds.ToString("000")
     MsgBox("Twitter server time=" & Format(lTwitterServerTime) & " Tweet Time=" & Format(lTimeOfTweet) & " ellapsed=" & lElapsedDisplay)
Since both timestamps are from the same Time Zone, it's not necessary to convert to local time!

Thank you for your time!