I am writing a .NET application with the Stack Exchange API (using the Stacky library) and I am using it to ask the server for some questions that occured in the last hour. However, I and the server are not in the same time zone, so if I ask it for questions from DateTime.Now.AddHours(-1)
to DateTime.Now
, it gives me questions from 9 hours ago to 8 hours ago.
This is obviously a problem. Right now I am getting over it by asking for questions from DateTime.Now.AddHours(7)
to DateTime.Now.AddHours(8)
, but will obviously not work for people in other time zones. How can I compensate for the time difference in such a way that it will work for all users?
DateTime.ToUniversalTime
, so problem solved. If you copypaste that into an answer, I'll mark it as such.