ASP.NET MVC:DateTime 的格式为 MM/dd/yyyy 但我需要 dd/mm/yyyy
ASP.NET MVC : DateTime is taking format as MM/dd/yyyy but I need in dd/mm/yyyy
public class Employee
{
[DataType(DataType.Date)]
public DateTime DateOfRegistration { get; set; }
}
我的.cshtml:
@Html.EditorFor(model => model.DateOfRegistration,
new { htmlAttributes = new { @class = "form-control", @readonly = "true" } })
jQuery代码:
$('input[type=datetime]').datepicker({
dateFormat: "dd/M/yy",
changeMonth: true,
changeYear: true,
});
请帮帮我 - 如何获得 dd/mm/yyyy
格式的日期?
将您的日期格式更改为:dateFormat: "dd/M/yy",
为此:dateFormat: 'dd/mm/yy'
希望对您有所帮助
<!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>
如需更多帮助,请参阅 Change Date Format of jQuery Datepicker to dd/mm/yy
public class Employee
{
[DataType(DataType.Date)]
public DateTime DateOfRegistration { get; set; }
}
我的.cshtml:
@Html.EditorFor(model => model.DateOfRegistration,
new { htmlAttributes = new { @class = "form-control", @readonly = "true" } })
jQuery代码:
$('input[type=datetime]').datepicker({
dateFormat: "dd/M/yy",
changeMonth: true,
changeYear: true,
});
请帮帮我 - 如何获得 dd/mm/yyyy
格式的日期?
将您的日期格式更改为:dateFormat: "dd/M/yy",
为此:dateFormat: 'dd/mm/yy'
希望对您有所帮助
<!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>
如需更多帮助,请参阅 Change Date Format of jQuery Datepicker to dd/mm/yy