I have a date in this entity "YYYY / MM / DD". Now I want to get this day from this format. How can I get it using javascript or jquery? One way is
$(document).ready(function() { var d = new Date(); alert(d.getDay()); } );
but the problem here is that the d variable contains a date in this format
Sat Jan 07 2012 18:16:57 GMT+0200 (FLE Standard Time)
How can I get the day from the date in the above format?
This is what my function looks like
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);
What I am doing is transferring the date in the "YYYY-MM-DD" format, and it converts that date to a unix timestamp, and then I get the day, and then return the day like Sunday or Monday, etc. But here he only returns on Friday, which is wrong. When I change day to day, it should return the same day in the array.
2619
source share