WayBehind WayBehind - 1 year ago 82
jQuery Question

Display Day of the Week after Date with bootstrap-datepicker

I'm using bootstrap-datepicker and would like to also display the actual day of the week in the text field right after the date.


12/01/2014 Monday

my datepicker configuration

$(document).ready(function () {

format: "mm/dd/yyyy",
weekStart: 1,
autoclose: true,
todayHighlight: true,

The actual datepicker source is here:


Answer Source

You can try something like this, only add this part to your code:

$('#calendar').change(function () { //Your date picker input
    var eventDate = $('#calendar').val();
    var dateElement = eventDate.split("/");
    var dateFormat = dateElement[2]+'-'+dateElement[0]+'-'+dateElement[1];
    var date = new Date(dateFormat+'T10:00:00Z'); //To avoid timezone issues
    var weekday = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
    var day = weekday[date.getDay()];
    $('#calendar').val($('#calendar').val() + ' ' + day);

Hope works for you.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download