I'm using bootstrap date picker, but unfortunately it doesn't support jalali calender. I searched on google for conversion of it, but I didn't find anything useful. So I need to change the datepicker and customize it like this image below.
Go to line 1399 and find format: 'mm/dd/yyyy' . Now you can change the date format here.
$(document). mouseup(function (e) { $('#example1'). Close(); });
You have to use . show() method to keep your dateTimePicker visible, note that all the DateTimePicker's functions are reachable via the data attribute e.g.
download file zip persian-datepicker in persian-datepicker then added in file zip, Sample code is available
<script type="text/javascript" src="../lib/jquery.js"></script>
<link href="../lib/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../lib/bootstrap/js/bootstrap.min.js"></script>
<link href="css/persian-datepicker-0.4.5.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../lib/persian-date.js"></script>
<script type="text/javascript" src="js/persian-datepicker-0.4.5.min.js"></script>
then html code sample added
<div class="form-group col-xs-6">
<label>Select Date</label>
<input id="observer" type="text" class="form-control"/>
</div>
<div class="form-group col-xs-6">
<div id="inlineDatepicker" data-date="2016/12/13 12:20" class="col-xs-12"> </div>
<div class="col-xs-12">
<input id="inlineDatepickerAlt" type="text" class="form-control"/>
</div>
then script jquery added
<script type="text/javascript">
$(document).ready(function () {
$("#observer").persianDatepicker({
altField: '#observer',
altFormat: "YYYY MM DD HH:mm:ss",
observer: true,
format: 'YYYY/MM/DD HH:mm:ss',
timePicker: {
enabled: true
},
});
//inline datepicker
$("#observer").css( "z-index", "1000" );
window.pd = $("#inlineDatepicker").persianDatepicker({
timePicker: {
enabled: true
},
altField: '#inlineDatepickerAlt',
altFormat: "YYYY/MM/DD HH:mm",
checkDate: function (unix) {
var output = true;
var d = new persianDate(unix);
if (d.date() == 20) {
output = false;
}
return output;
},
checkMonth: function (month) {
var output = true;
if (month == 1) {
output = false;
}
return output;
}, checkYear: function (year) {
var output = true;
if (year == 1396) {
output = false;
}
return output;
}
}).data('datepicker');
$("#inlineDatepicker").pDatepicker("setDate", [1391, 12, 1, 11, 14]);
});
</script>
If time did not want it is jquery
$("#observer").persianDatepicker({
altField: '#observer',
altFormat: "YYYY MM DD",
observer: true,
format: 'YYYY/MM/DD',
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With