Closed lalustine7 closed 6 years ago
Hi, @lalustine7 Sorry for the late reply. Actually, I have not noticed you have created an issue.
Looking through your code I found that you have not set Nepali formatted date as value. So plugin through Invalid nepali number
error.
We have calendarFunctions.bsDateFormat()
to convert formated nepali date.
<p>
<label>From Date: </label>
<input type="hidden" value="2018-10-10" name="eng_start_date">
<input type="text" value="" name="start_date" class="nepalidatepicker">
</p>
<p>
<label>To Date: </label>
<input hidden="text" value="2018-12-10" name="eng_end_date">
<input type="text" value="" name="end_date" class="nepalidatepicker">
</p>
<script type="text/javascript">
$(document).ready(function () {
var eng_start_date = $('input[name="eng_start_date"]').val();
var startDate = new Date(eng_start_date);
var startNepaliDate = calendarFunctions.getBsDateByAdDate(startDate.getFullYear(),
startDate.getMonth() + 1, startDate.getDate());
//startNepaliDate = startNepaliDate.bsYear + '-' + startNepaliDate.bsMonth + '-' + startNepaliDate.bsDate;
var formattedStartNepaliDate = calendarFunctions.bsDateFormat("%y-%m-%d", startNepaliDate.bsYear, startNepaliDate.bsMonth, startNepaliDate.bsDate);
$('input[name="start_date"]').val(formattedStartNepaliDate);
var eng_end_date = $('input[name="eng_end_date"]').val();
var endDate = new Date(eng_end_date);
var endNepaliDate = calendarFunctions.getBsDateByAdDate(endDate.getFullYear(),
endDate.getMonth() + 1, endDate.getDate());
//endNepaliDate = endNepaliDate.bsYear + '-' + endNepaliDate.bsMonth + '-' + endNepaliDate.bsDate;
var formattedEndNepaliDate = calendarFunctions.bsDateFormat("%y-%m-%d", endNepaliDate.bsYear, endNepaliDate.bsMonth, endNepaliDate.bsDate);
$('input[name="end_date"]').val(formattedEndNepaliDate);
$('.nepalidatepicker').nepaliDatePicker({
dateFormat: '%y-%m-%d',
closeOnDateSelect: true
});
});
</script>
Thank You for your reply. I was waiting for your reply and thanks for solving my issues. I would like to ask some questions so it would be easier for me.
1) How to change date format so i would get date '2075-05-25' instead of '2075-5-25'? 2) How to change the nepali date to english date on date change function ? Can we use dateChange or dateSelect function like this: $('.nepalidatepicker').nepaliDatePicker({ dateFormat: '%y-%m-%d', closeOnDateSelect: true, dateChange : function(e){ //here convert the nepali date into english date } });
Hoping for your reply again. Thank You, Lal Kumar Rai
Hi @lalustine7,
How to change date format so i would get date '2075-05-25' instead of '2075-5-25'?
pull request
.How to change the nepali date to english date on date change function ?
Event Handlers
for handlering change events. Please check demo & documentations: https://nepali-date-picker.herokuapp.com/demo/ for more details.
$('.nepalidatepicker').nepaliDatePicker({
dateFormat: '%y-%m-%d',
closeOnDateSelect: true
});
$('.nepalidatepicker').on("dateChange", function (event) { console.log(event); // English date console.log(event.datePickerData.adDate); });
Thank Your for your reply again.
1) Currently, does not support 2 digit month/date format. For that we need to do some changes in code. May be you can try out and send pull request.
2)Nepali date picker plugin has Event Handlers for handlering change events. Please check demo & documentations: https://nepali-date-picker.herokuapp.com/demo/ for more details.
shows invalid nepali number when try to edit the date in edit page.want solution to edit the date in edit page
Thank you for such good library. But i am facing an issue while editing project start date and end date. When i supply english date directly, it is obvious to show invalid nepali number. But when i store the english start date and english end date in hidden input and later use getBsDateByAdDate function, it do not give error but the nepali calendar is not set to given date. Can you help me with this?
My datepicker setup is like below:
My datepicker when providing nepali date after conversion like in setup:
My datepicker date is not set according to given date input: