jquery - Display Day of the Week after Date with bootstrap-datepicker -
i'm using bootstrap-datepicker , display actual day of week in text field right after date.
example: 12/01/2014 monday
my datepicker configuration
$(document).ready(function () { $('#calendar').datepicker({ format: "mm/dd/yyyy", weekstart: 1, autoclose: true, todayhighlight: true, }); });
the actual datepicker source here:
you can try this, add part 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 you.
Comments
Post a Comment