0
public class Employee
{
       [DataType(DataType.Date)]
        public DateTime DateOfRegistration { get; set; }
}

My .cshtml:

@Html.EditorFor(model => model.DateOfRegistration, 
                new { htmlAttributes = new { @class = "form-control", @readonly = "true" } })

jQuery code:

$('input[type=datetime]').datepicker({
        dateFormat: "dd/M/yy",
        changeMonth: true,
        changeYear: true,
    });

Please help me - how can I get date in dd/mm/yyyy format?

enter image description here

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

2 Answers2

0

Change your dateFormat from this: dateFormat: "dd/M/yy",

to this: dateFormat: 'dd/mm/yy'

More info here and here.

Hope this helps

javachipper
  • 519
  • 4
  • 15
0

<!doctype html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>jQuery UI Datepicker - Format date</title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  <link rel="stylesheet" href="/resources/demos/style.css">
  <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  <script>
    $(function() {
      $("#datepicker").datepicker();
      $("#format").on("change", function() {
        $("#datepicker").datepicker("option", "dateFormat", $(this).val());
      });
    });
  </script>
</head>

<body>

  <p>Date: <input type="text" id="datepicker" size="30"></p>

  <p>Format options:<br>
    <select id="format">
      <option value="dd-mm-yy">dd-mm-yy</option>
      <option value="dd/mm/yy">dd/mm/yy</option>
    </select>
  </p>


</body>

</html>

for more help kindly refer Change Date Format of jQuery Datepicker to dd/mm/yy

Arvind Maurya
  • 910
  • 12
  • 25