title: How use c# to convert mongodb BsonDateTime (UTC) to local time
body: <p>In my C# console application project I'm using MongoDB.Driver.2.4.3 with connection to MongoDB 3.2.10.</p>
  
  <p>How would I convert "playerInBrazil.birthdate" in my code which is defined as BsonDateTime (I believe this is in UTC) to my local datetime value (Eastern Standard Time)?</p>
  
  <p>I was trying to do subtract operation(not allowed) and DateTime.ToLocalTime Method () but couldn't make it work.</p>
  
  <pre><code>static void Main(string[] args)
      {
          DateTime myTimeConvert = DateTime.Now;
          var client = new MongoClient("mongodb://localhost:27017");
          var DB = client.GetDatabase("football");
  
          var players = DB.GetCollection&lt;Player&gt;("players");
  
          var playersInBrazil = players.AsQueryable()
                           .Where(p =&gt; p.country == "Brazil");
          foreach (var playerInBrazil in playersInBrazil)
          {
              Console.Write(playerInBrazil.firstname);
              Console.Write(" birthdate in UTC time is ");
              Console.Write(playerInBrazil.birthdate);
              Console.Write(" and in my local time is ");
              //myTimeConvert =?
              Console.WriteLine(myTimeConvert);
  
          }
  
      }
  
      internal class Player
      {
          public ObjectId Id { get; set; }
          public string firstname { get; set; }
          public BsonDateTime birthdate { get; set; }
          public string country { get; set; }
          public double goals { get; set; }
      }
  }
  </code></pre>