javascript - 我想在输入字段中将日期格式更改为 yyyy-mm-dd
问题描述
<input type="text" name="daterange" class="form-control input-box-style " PLACEHOLDER="calendar" id="dateone" />
<script type="text/javascript">
$(document).ready(function() {
updateConfig();
function updateConfig() {
var options = {};
options.opens = "center";
options.ranges = {
format: 'YYYY-MM-DD',
'Today': [moment(), moment()],
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
'This Month': [moment().startOf('month'), moment().endOf('month')],
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
};
$('#dateone').daterangepicker(options, function(start, end, label) {
var startDate = start.format('YYYY-MM-DD'); var endDate = end.format('YYYY-MM-DD');
passDate(startDate,endDate);
});
}
});
function passDate(startDate,endDate) {
//alert(endDate);
$.ajax({
type: "POST",
url: "user_event_datepick.php",
//data: 'startDate='+startDate,
data: {
startDate: startDate,
endDate:endDate
},
success: function(response){
// alert(response);
$('#cat').html(response);
}
});
}
</script>
当我将日期传递到搜索页面时,日期值显示为 mm/dd/yyyy....您能帮我颠倒顺序并将 / 移至 -
解决方案
推荐阅读
- c# - DynamicRouteValueTransformer 改变值没有任何影响
- python - multiprocessing.Pool.map() 有效,但 Pool.apply() 无效
- sccm - Powershell:查找正在运行的进程,如果进程正在运行则中止脚本,否则继续执行脚本
- angular - 如何使用angular8在formarray中单击编辑/查看时一次显示一个表单详细信息
- php - 使用 move_uploaded_file 函数在服务器上上传文件,该函数在 localhost 但不在实时服务器上工作
- ios - 语音识别器在 ios 13 背景中不起作用
- kubernetes - 通过 localhost 和端口转发的 Kubernetes 访问应用程序
- java - 合并 web.xml 期间的 Maven 货物不包括所有错误页面
- reactjs - 无法访问函数外的数据
- shiny - 为什么条件面板在第一次尝试时不起作用?