I am facing one issue fomrating the date
Here is my function
$('input[name="issued_date"]').daterangepicker({
singleDatePicker: true,
showDropdowns: true,
issued_date: moment().startOf('hour'),
locale: {
"format": "YYYY-MM-DD",
"separator": "-"
}
});
$('input[name="expiry_date"]').daterangepicker({
singleDatePicker: true,
showDropdowns: true,
expiry_date: moment().startOf('hour'),
locale: {
"format": "YYYY-MM-DD",
"separator": "-"
}
});
It showing dates and time in format like this "2019-05-30"
If I change it like this
$('input[name="issued_date"]').daterangepicker({
singleDatePicker: true,
showDropdowns: true,
issued_date: moment().startOf('hour'),
locale: {
"format": "DD-MM-YYYY",
"separator": "-"
}
});
$('input[name="expiry_date"]').daterangepicker({
singleDatePicker: true,
showDropdowns: true,
expiry_date: moment().startOf('hour'),
locale: {
"format": "DD-MM-YYYY",
"separator": "-"
}
});
The format it shows correct.... It will show 05-05-2020 But I am facing one issue in another function .... I need to check the start_date should less than end_date...
So at the time of form submission.... I am returning another function like this
$(".someclass").click(function () {
$('.loading').show();
var start_date = document.getElementById('id_issued_date').value;
var end_date = document.getElementById('id_expiry_date').value;
if (start_date < end_date)
{
var url = "{% url 'add' %}";
$.ajax({
type: 'POST',
url: url,
data: $("#new_form").serialize(),
cache: false,
success: function (data, status) {
if (data['status'] == "success") {
$('#form_modal').modal('hide');
toastr.success(data.message);
$('#form_modal').children().remove();
url = getPathFromUrl(document.location.href)
window.location.href = url
}
else {
$('#form_modal').html(data);
}
}
});
}
else{
toastr.error('start date should be less than End Date');
}
});
But if I Pass a date like this start date 01/06/2019 and end date is 05/05/2020 it will not work
Actually the start_Date is less than end date