title: Getting day from date using jquery/javascript
body: <p>I have a date in this formate "YYYY/MM/DD". Now I want to get the day from this format. How can I get it using javascript or jquery? One way is this</p>
  
  <pre><code> $(document).ready(function() {
  
  var d = new Date();
  
  alert(d.getDay());
   } );
  </code></pre>
  
  <p>but the problem here is that d variable contains date in this format</p>
  
  <pre><code>Sat Jan 07 2012 18:16:57 GMT+0200 (FLE Standard Time)
  </code></pre>
  
  <p>How can I get day from date in above format?</p>
  
  <hr>
  
  <p>Here is how my function look like</p>
  
  <pre><code>function dayOfWeek(d) {
              var dayNames = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Sunday');
              var currentDate = Math.round(+new Date(d)/1000);
              var nData = new Date(currentDate);
              //alert(nData);
              //alert(nData.getDay());
              //var day = d.split("-")[2];
              //var t = day.replace("0","");
              //alert(t);
              return dayNames[nData.getDay()];
          }
  </code></pre>
  
  <p>What I am doing is I am passing date in "YYYY-MM-DD" format and it converts that date to unix timestamp and then I get the day and then return the day as Sunday or Monday etc. But here it only returns Friday which is incorrect. When I change the day in date it should return the same day in array.</p>