title: Date time conversion in javascript and php
body: <p>I am getting different <code>time conversions</code> while using a <code>datetimepicker</code> in <code>js</code> and converting the <code>date</code> in <code>php</code></p>
  
  <p>My <strong>PHP</strong> code is:</p>
  
  <pre><code>&lt;?php
      date_default_timezone_set('Asia/Calcutta');
      echo date('Y-m-d H:i:s A',strtotime('5/29/2013 00:00PM'));
      //outputs 1970-01-01 05:30:00 AM
      //echo date('Y-m-d H:i:s A',strtotime('5/29/2013 0:00AM'));//same result
      //tested on http://writecodeonline.com/php/
  ?&gt;
  </code></pre>
  
  <p>And <strong>js</strong></p>
  
  <pre><code>&lt;script&gt;
      var s='5/29/2013 0:00PM';
      parseDate= function(s) {
          var currentYear, currentMonth, currentDay, currentHour, currentMinute;
          arr=s.split(' ');
          dateArr=arr[0].split('/');
          currentYear=dateArr[2];
          currentMonth=parseInt(dateArr[0])-1;
          currentDay=dateArr[1];
          timeArr=arr[1].split(':');
          currentHour=timeArr[0];
  
          if(s.contains('AM')===false)
          {
              currentHour=parseInt(timeArr[0])+12;
              currentMinute=parseInt(timeArr[1].replace('PM'));
          }
          else
          {
              currentMinute=parseInt(timeArr[1].replace('AM'));
          }
          console.log(currentYear,currentMonth,currentDay,currentHour,currentMinute,0,s.contains('AM'));
          return new Date(currentYear,currentMonth,currentDay,currentHour,currentMinute,0);
  
      }
      console.log(new Date());
      alert(parseDate(s));
      //outputs Wed May 29 2013 12:00:00 GMT+0530 (India Standard Time)
  &lt;/script&gt;
  </code></pre>
  
  <p>Fiddle <a href="http://jsfiddle.net/36vjH/" rel="nofollow">http://jsfiddle.net/36vjH/</a></p>