title: sending JSON dates to google charts API from Perl
body: <p>I have a small dancer application which serves up some HTML (including the javascript to call the google charts API) and for other URLs queries a database and returns the data in encoded JSON in a form you can pass to google.visualization.DataTable. The javascript queries the dancer app for the JSON data then passes it into the google charts API - A simplified version is:</p>
  
  <pre><code>    &lt;script type="text/javascript" src="https://www.google.com/jsapi"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
  
        google.load('visualization', '1.0', {'packages':['corechart']});
        google.setOnLoadCallback(initialize);
  
  function initialize() {
      var res = $.ajax({
          url: "/data/2",
          dataType:"json",
          async: false,
          data: "{}",
          contentType: "application/json",
          error: function(jqXHR, textStatus, errorThrown) {
               alert('textStatus ' + textStatus);
               alert('errorThrown ' + errorThrown);
          }
      });
      jsonData = res.responseText;
      var data = new google.visualization.DataTable(jsonData);
  
      var chart = new google.visualization.BarChart(document.getElementById('chart_div'));
      chart.draw(data, {width: 400, height: 240});
  
  }
      &lt;/script&gt;
  </code></pre>
  
  <p>The problem is that some of the data returned by the Perl includes dates/timestamps and so should have the type set to "datetime":</p>
  
  <pre><code>{"rows":[{"c":[{"v":"WHAT_CAN_I_PUT_HERE"},{"v":"2095"}]}],"cols":[{"type":"datetime","label":"DTU"},{"type":"number","label":"COUNT"}]}
  </code></pre>
  
  <p>In Javascript you could create a date to pass to the google charts API with:</p>
  
  <pre><code>new Date(2012, 1, 08, 09, 32, 0)
  </code></pre>
  
  <p>How can I send a date encoded in JSON from Perl such that the google charts API understands it? If you cannot what other options might be available to me?</p>