I have two codes to return the day of the week, but in the first it returns undefined, and in the second it returns the wrong day, for example on 22/05/2016 it returns Wednesday, and the correct one would be Sunday.
Code 1:
$(document).ready(function(){
$("input#dataR").blur(function(){
var data = $("#dataR").val();
var teste = new Date(data);
var dia = teste.getDay();
var semana = new Array(6);
semana[0]='Domingo';
semana[1]='Segunda-Feira';
semana[2]='Terça-Feira';
semana[3]='Quarta-Feira';
semana[4]='Quinta-Feira';
semana[5]='Sexta-Feira';
semana[6]='Sábado';
alert(semana[dia]);
});
});
Code 2:
$(document).ready(function(){
$("input#dataR").blur(function(){
var data = $("#dataR").val();
var arr = data.split("/");
var teste = new Date(arr[0],arr[1],arr[2]);
var dia = teste.getDay();
var semana = new Array(6);
semana[0]='Domingo';
semana[1]='Segunda-Feira';
semana[2]='Terça-Feira';
semana[3]='Quarta-Feira';
semana[4]='Quinta-Feira';
semana[5]='Sexta-Feira';
semana[6]='Sábado';
alert(semana[dia]);
});
});