How to get Twitter server time?

Jan 25, 2014 at 2:38 AM
Hi
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 ?

Thanks!
Coordinator
Jan 25, 2014 at 9:36 PM
Hi,

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:
    twitterCtx.ResponseHeaders["Date"]
@JoeMayo
Jan 26, 2014 at 1: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!