title: How to convert a date from SQL server?
body: <p>I have a query that brings data back from the database.  I have php code to return the data in an array of arrays to convert to a JSON.</p>
  
  <pre><code>while($imageData = sqlsrv_fetch_array($result))
          {
              $images[] = array('FilePath' =&gt; str_replace($imageData['FilePath'],"\\","\\\\"), 
                  'FileName' =&gt; $imageData['FileName'], 
                  'FileExtension' =&gt; $imageData['FileExtension'], 
                  'WholeNumber' =&gt; $imageData['Whole Nbr'], 
                  'Type' =&gt; $imageData['Type'], 
                  'Size' =&gt; $imageData['Size'], 
                  'Revision' =&gt; $imageData['Revision'], 
                  'OtherNumber' =&gt; $imageData['Other Nbr'], 
                  'SheetNumber' =&gt; $imageData['Sheet Nbr'], 
                  'SheetsTotal' =&gt; $imageData['Of Sheets'], 
                  'FrameNumber' =&gt; $imageData['Frame Nbr'], 
                  'FramesTotal' =&gt; $imageData['Of Frames'], 
                  'DocumentTitle' =&gt; $imageData['Doc Title'], 
                  'Volume' =&gt; $imageData['Volume'], 
                  'Note' =&gt; $imageData['Note'], 
                  'Print' =&gt; $imageData['Prnt'], 
                  'Obs' =&gt; $imageData['Obs'], 
                  'AcquireDate' =&gt; $imageData['Acquire Date'], 
                  'Source' =&gt; $imageData['Source'], 
                  'BaseDoc' =&gt; $imageData['Base Doc'], 
                  'AccDocNbr' =&gt; $imageData['Acc Doc Nbr'], 
                  'CommonSubDirectory' =&gt; $imageData['CommonSubDirectory']);
          }   
  </code></pre>
  
  <p>Javascript then converts it to a JSON:</p>
  
  <pre><code>function SendRequest(source, params) {
  
      var http = new XMLHttpRequest();
  
      try {
  
          http.open("GET", source + '?' + params, false);
          http.setRequestHeader("Content-type","application/json");
          http.onload = function() {
              //alert('in function');
          }
          http.send(params);
      }
  
      catch (err) {
          alert(err.message);
      }
  
      return JSON.parse(http.responseText);
  
  }
  </code></pre>
  
  <p>Then getting data back like this allows me to access all the members EXCEPT the AcquiredDate</p>
  
  <pre><code>data = SendRequest;
  var newText  = document.createTextNode(data[r].Type);
  </code></pre>
  
  <p>But this does not work
      var newText  = document.createTextNode(data[r].AcquireDate);</p>
  
  <p>I get an object back.  I can print it out with </p>
  
  <pre><code>alert(JSON.stringify(data[r].AcquireDate));
  </code></pre>
  
  <p>Which looks like this:
      {"date":"2010-04-28 00:00:00","timezone_type":3,"timezone":"Europe/Paris"}</p>
  
  <p>But if I try to parse it I get an error</p>
  
  <pre><code>acquireDate = JSON.parse(data[r].AcquireDate).date;
  </code></pre>
  
  <p>or
      acquireDateObj = JSON.parse(data[r].AcquireDate);
      acquireDate = acquireDateObj.date;</p>
  
  <p>I get JSON.parse: unexpected character at line 1 column 2 of the JSON data</p>
  
  <p>Why can JSON stringify but not parse?  And what is column 2?  A quote?  The caharcter d?  Both of those look valid to me.</p>