Oto wiele informacji na temat sposobu korzystania z obiektu Date javascript.
Oto kod Proponuję Ci:
$(function() {
$("#datepicker").datepicker({
onSelect: function(dateText, dateObj){
//You can get your date string that way
console.log(dateText);
//You can get a few value about the date, look in your console to see what you can do with that object
//i.e. - console.log(dateObj.selectedDay)
console.log(dateObj);
//You can see the result of the date in string that way
$('.string').append(dateText);
currDate = new Date(dateText);
//You can have a complete Date object using the Date javascript method
console.log(currDate);
//The Date object in javascript provides you all you need then
//Get the number of day in a week, from 0(Sunday) to 6(Saturday)
$('.getday').append(currDate.getDay());
//Create a function to see day Sun - Sat
function getWeekDay(date) {
var days = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat']
return days[ date.getDay() ]
}
//Then we use it
$('.getweekday').append(getWeekDay(currDate));
}
});
});
możesz zobaczyć moje skrzypce tam: https://jsfiddle.net/qapw32Lp/
Tutaj jest doskonałym źródłem informacji można użyć również abotu obiektu Date: http://javascript.info/tutorial/datetime-functions
Dzięki człowieku, wydaje się działać teraz! Jestem nowy w js, więc to było naprawdę pomocne – klekmek
nie ma za co! proszę przyjąć odpowiedź, jeśli uznasz to za przydatne :) – rikpg