Here is a lot of information on how to use a Date javascript object.
Here is the code that I offer you:
$(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 //ie - 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)); } }); });
You can see my fiddle: https://jsfiddle.net/qapw32Lp/
Here is a great source of information that you can use also in the Date object: http://javascript.info/tutorial/datetime-functions
source share