5

I now it has been aswer before, the problem is that I get the date from an input is not the current date.

I need to get the day of the week. Currently I get the date with this format :

11/09/2013

But I want it like:

Saturday/02/2013. 

I'm using datepicker to show the calendar, so it could be some solution that would help me using the same plugin.

GioBot
  • 613
  • 5
  • 10
  • 17

1 Answers1

13
var date = new Date();
var weekdays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];

var weekday = weekdays[date.getDay()];
var month = date.getMonth() + 1;
var year = date.getYear();
Nick McCurdy
  • 17,658
  • 5
  • 50
  • 82
Hello World
  • 1,102
  • 2
  • 15
  • 33
  • The problem is that I'm using the value of a variable, It works perfect when I use new Date, but how to do it whit a varible that I get from the datepicker? – GioBot Nov 09 '13 at 22:40
  • 1
    You can get a date from your datepicker with some kind of date parser. This question http://stackoverflow.com/questions/2587345/javascript-date-parse shows a nice simple date parsing function for dates in the format `yyyy-mm-dd`. you should be able to customize that for the format you get back from the date picker. You should also check, some datepicker libraries have a 'getDate' kind of method that should give you the date as a Javascript Date. – mr rogers Nov 09 '13 at 22:52