title: get server time on the client side in javascript / jquery
body: <p>I want to use, on the client side, dates as they are on the server side.<br>
  for example- if the current time on the server side is '2011-09-21 15:00:00', I want to be able to get a javascript <code>Date</code> object with that value ('15:00:00'), even if the client is in a different time zone.<br>
  what i've tried so far:<br>
  suppose the server time is '15:00:00' and client time is '17:00:00', The <code>Date</code> object I get on the client side always contains '16:00:00', for some reason.<br>
  here's what i've tried:<br>
  1. sending a .net DateTime object to the client (it gets serialized as 
  <code>"Date\12345...\"</code>), and on the client side converting it to a <code>Date</code> object:  </p>
  
  <pre><code>function parseServerDate(strDate) {
      return new Date(parseInt(strDate.substr(6)));
  }
  </code></pre>
  
  <p>OR converting the .net <code>DateTime</code> object into a UTC number:</p>
  
  <pre><code>    // returns the number of milliseconds since Jan 1, 1970 (useful for converting C# dates to JS dates)
      public static double UnixTicks(this DateTime dateTime)
      {
          DateTime epoch = new DateTime(1970, 1, 1);
          DateTime d2 = dateTime.ToUniversalTime();
          TimeSpan ts = new TimeSpan(d2.Ticks - epoch.Ticks);
          return ts.TotalMilliseconds;
      }
  </code></pre>
  
  <p>and then creating a new <code>Date</code> object:<br>
  <code>new Date(milliseconds)</code> or <code>new Date().setTime(milliseconds)</code>, both of which produced the same result as above.</p>
  
  <p>should I maybe send the server's timezone offset as well, and handle the difference in the client side?<br>
  What's the best way to go about it?</p>