当前我的日期输入格式是mm / dd / yyyy,我希望将其设置为dd / mm / yyyy。
我该如何更改?
我正在使用Bootstrap 4
在我的代码下面:
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com /bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384- MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
</head>
<body style="background-color:white">
<div class="container" style="background-color:white">
<div class="row justify-content-md-center">
<div class="col-sm col-lg-5 pads rounded border" style="background-color:#f2f2f2">
<form action="" method="POST">
<div class="form-group row">
<label class="col-sm-2 col-form-label font-weight-bold">For</label>
<div class="col-sm-10">
<input class="form-control" type="date" id="date-input" name="order-date" required>
</div>
</div>
<div class="form-group row">
<div class="col-sm">
<button type="submit" class="btn btn-primary btn-block">CONTINUE</button>
</div>
</div>
</form>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
</body>
</html>
答案 0 :(得分:0)
对于纯JS,请使用:
format: 'dd/mm/yyyy'
对于JQuery,请使用:
dateFormat: 'dd/mm/yyyy'
如果您使用的是日期选择器,则可以使用JQuery / Bootstrap:
$( ".datepicker" ).datepicker({
format: 'yyyy-mm-dd'
});