Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

175
Views
Change Datepicker Date Format for Sql

https://jsfiddle.net/jquerybyexample/dxbtp/494/

i used this code for Date Range but this input format is MM/dd/yyyy . i want change this format MM/dd/yyyy for send my Database.

if i change this line

        var dtFormatted = mm + '/'+ dd + '/'+ y;

to

        var dtFormatted = dd+ '/'+ mm + '/'+ y;

input tag doesn't work properly

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Here is a working demo:

<div>
    <input type="text" id="txtFromDate" />To:
    <input type="text" id="txtToDate" />
</div>
<link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/themes/base/jquery-ui.css" rel="stylesheet" />
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"></script>
    <script>
        $('input[id$=txtFromDate]').datepicker({
            dateFormat: 'dd/mm/yy'
        });
        $('input[id$=txtToDate]').datepicker({
            dateFormat: 'dd/mm/yy'
        });
    </script>

result: enter image description here

about 4 years ago · Juan Pablo Isaza Report

0

set dtFormatted as a string, with the format below.

var dtFormatted = "dd/mm/yy";
about 4 years ago · Juan Pablo Isaza Report

0

 <input asp-for="@Model.Reservation.StartDate" type="text" class="datepicker" id="txtFromDate" autocomplete="off" required placeholder="Check In">

<input asp-for="@Model.Reservation.EndDate" type="text" class="datepicker" autocomplete="off" id="txtToDate" required placeholder="Check Out">

<script type="text/javascript">
    
    $(document).ready(function () {
        $('#txtToDate').datepicker({
            dateFormat: "dd/mm/yy"
        });
        $("#txtFromDate").datepicker({
            dateFormat: "dd/mm/yy",
            minDate: new Date(),
            onSelect: function (date) {
                var date1 = $('#txtFromDate').datepicker('getDate');
                var date = new Date(Date.parse(date1));
                date.setDate(date.getDate() + 1);
                var newDate = date.toDateString();
                newDate = new Date(Date.parse(newDate));
                $('#txtToDate').datepicker("option", "minDate", newDate);
            }
        });
    });
</script>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!