title: Javascript date from c# DateTime
body: <p>I'm having trouble creating a js date variable from a c# datetime. I'm noticing some strange behaviour with jquerys .val() method.</p>
  
  <p>An input element holds the date info, like this:</p>
  
  <pre><code>@Html.HiddenFor(t =&gt; t.Tasks[i].Task.Deadline, new { @class = "task-end", @Value = Model.Tasks[i].Task.Deadline.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds })
  </code></pre>
  
  <p>In the javascript, I'm doing this:</p>
  
  <pre><code>var date = new Date($("MyDateFromHiddenField").val());
  </code></pre>
  
  <p>Writing this date to the console gives invalid date.</p>
  
  <p>If I write <code>$("MyDateFromHiddenField").val()</code> to the console I get <code>1372854195130</code></p>
  
  <p>Hardcoding the date with this number will give me a valid date:</p>
  
  <pre><code>var date = new Date(1372854195130); &lt;---Valid
  </code></pre>
  
  <p>For some reason, new Date() doesn't like the .val() method.</p>
  
  <p>Example: <a href="http://jsfiddle.net/hZ7bm/1/" rel="nofollow">http://jsfiddle.net/hZ7bm/1/</a></p>