title: Milliseconds in DateTime.Now on .NET Compact Framework always zero?
body: <p>i want to have a <strong>time stamp</strong> for logs on a <strong>Windows Mobile project</strong>. The accuracy must be in the range a hundred milliseconds at least.</p>
  
  <p>However my call to <code>DateTime.Now</code> returns a <code>DateTime</code> object with the <code>Millisecond</code> property set to zero. Also the <code>Ticks</code> property is rounded accordingly.</p>
  
  <p><strong>How to get better time accuracy?</strong> <br>
  <em>Remember, that my code runs on on the Compact Framework, version 3.5. I use a HTC touch Pro 2 device.</em></p>
  
  <p><strong>Based on the answer from MusiGenesis i have created the following class which solved this problem:</strong></p>
  
  <pre><code>/// &lt;summary&gt;
  /// A more precisely implementation of some DateTime properties on mobile devices.
  /// &lt;/summary&gt;
  /// &lt;devdoc&gt;Tested on a HTC Touch Pro2.&lt;/devdoc&gt;
  public static class DateTimePrecisely
  {
      /// &lt;summary&gt;
      /// Remembers the start time when this model was created.
      /// &lt;/summary&gt;
      private static DateTime _start = DateTime.Now;
      /// &lt;summary&gt;
      /// Remembers the system uptime ticks when this model was created. This
      /// serves as a more precise time provider as DateTime.Now can do.
      /// &lt;/summary&gt;
      private static int _startTick = Environment.TickCount;
  
      /// &lt;summary&gt;
      /// Gets a DateTime object that is set exactly to the current date and time on this computer, expressed as the local time.
      /// &lt;/summary&gt;
      /// &lt;returns&gt;&lt;/returns&gt;
      public static DateTime Now
      {
          get
          {
              return _start.AddMilliseconds(Environment.TickCount - _startTick);
          }
      }
  }
  </code></pre>