title: .NET DateTime & TimezoneInfo.ConvertTime party
body: <p>The thing I want to do is quite simple:</p>
  
  <pre><code>    private static TimeZoneInfo Tzi = // ... custom timeZone I've set;
      public static DateTime ToTimeZone(DateTime dateTime, TimeZoneInfo target)
      {
          return TimeZoneInfo.ConvertTime(dateTime, Tzi, target);
      }
  </code></pre>
  
  <p>Idea is - all dates that come to the server are automatically converted to certain TimeZone and saved like that to DB (UTC, Central US, Pacific US, whatever).</p>
  
  <p>And this works quite well as long as timezone set on the server is same as Tzi. However, when that's not true, conversion fails - when creating DateTime instance .NET sets it to TimeZone of the machine and then TimeZoneInfo.ConvertTime(dateTime, Tzi, target) processes my request in a funky way. For example, let's say that Server TimeZone is Pacific (UTC -8), I set Tzi to Central (UTC -6), and I target Singapure (UTC +8).</p>
  
  <p>Now when I call TimeZoneInfo.ConvertTime(dateTime, Tzi, target) first "converts" dateTime from UTC -8 to UTC -6 (Tzi time zone), adding 2 hours... and only then from Tzi to target. </p>
  
  <p>Is there a way to signal to TimeZoneInfo.ConvertTime that dateTime I am sending is in TimeZone I am passing in as from parameter, and not in the TimeZone of server? </p>
  
  <p><strong>EDIT:</strong>
  OK, both answers are great recommendations, but it seems I have different kind of trouble. TimeZoneInfo.ConvertTime(dateTime, Tzi, target) seems to be working correctly, and the real culprit is actually:</p>
  
  <pre><code>return Json(new {data}, JsonRequestBehavior.AllowGet);
  </code></pre>
  
  <p>that outputs dates like: "Created":"/Date(1346810072950)/". I've confirmed that sent date is different depending on TimeZone on the server (AppPool restart is needed after changing server's TimeZone). Anyone have experience with this and suggestion on how to influence the way ASP.NET MVC outputs dates in JSON that's sent back to client?</p>