title: Using jquery countdown timer with mysql datetime?
body: <p>I know this question has been asked many times as I have found a few on google and also on stackoverflow.</p>
  
  <p>but none of them explained how to format my datetime in my php so it works in combination with jquery countdown timer. so I am going to ask it here in a hope i get someone shed a light on this for me.</p>
  
  <p>Basically what i am trying to do is to create a countdown timer which will work with mysql datetime.</p>
  
  <p>the datetime is stored in mysql so All need to do is to get the correct format in my php so the countdown timer could work with it.</p>
  
  <p>I am using this plugin: <a href="http://keith-wood.name/countdown.html" rel="nofollow">http://keith-wood.name/countdown.html</a></p>
  
  <p>and here is what i have so far:</p>
  
  <p>PHP formatting:</p>
  
  <pre><code>$end_date = date("m d Y H:i:s T", strtotime($row["end_date"])); 
  </code></pre>
  
  <p>Jquery/Javascript code:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
  $(function(){
      var countdown = $('#countdown'),
          ts = new Date(&lt;?php echo $end_date * 1000; ?&gt;),
          finished = true;
  
      if((new Date()) &gt; ts)
      {
          finished = false;
      }
  
      $('#defaultCountdown').countdown({
          timestamp   : ts,
          callback    : function(days, hours, minutes, seconds)
          {
              var message = "";
  
              message += days + " days, ";
              message += hours + " hours, ";
              message += minutes + " minutes, ";
              message += seconds + " seconds ";
  
              message = (finished ? "Countdown finished" : "left untill the New Year");
  
              countdown.html(message);
          }
      });
  
  });
  
  &lt;/script&gt;
  </code></pre>
  
  <p>when i run this code, all i get is <code>0 hours, 0 minutes, 0 seconds.</code></p>
  
  <p>I can only suspect that the issue is from formatting the datetime in my php section!</p>
  
  <p>or am i missing something else as well?</p>
  
  <p><strong>okay I have managed to minify the code to this:</strong></p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
   $(document).ready(function () {
      $('#defaultCountdown').countdown({
          until: new Date(&lt;?php echo $end_date; ?&gt;),
          compact: true
      });
  });
  
  &lt;/script&gt;
  </code></pre>
  
  <p>and changed the php to this:</p>
  
  <pre><code>$end_date = date("Y, n, j, G, i, s", strtotime($row["end_date"]));
  </code></pre>
  
  <p>However, the time shown in the coutdown timer is wrong (way off).</p>
  
  <p>the <code>$end_date</code> is: <code>September 22 2013 23:30:00 GMT</code> in mysql datetime</p>
  
  <p>but the jquery countdown timer is showing:</p>
  
  <pre><code>34d 06:21:48
  2013, 9, 22, 23, 30, 00
  </code></pre>
  
  <p>34days and 6 hours blah blah is absolutely wrong!</p>
  
  <p>what am i doing wrong here now?</p>