[英]How To Set Own Default Date In Material-Datetime-Picker
Here i am using Material-datetime-picker . 在这里,我正在使用Material-datetime-picker 。 but i need only Date for DOB(Date Of Birth).
但是我只需要DOB(出生日期)的日期。 therefore on initial time Default Date should be from 1990 What Changing Should i Apply In material-datetime-picker.js
因此,在初始时间,默认日期应为1990年,我应该对material-datetime-picker.js应用哪些更改
index.php 的index.php
var picker = new MaterialDatetimePicker({})
.on('submit', function(d) {
var dt = d.format("DD/MM/YYYY");
$("#dob").val(dt);
});
$('#dob').click(function () {
picker.open();
});
replace Code in material-datetime-picker.js 替换material-datetime-picker.js中的代码
if (!this.value) {
// TODO hack
// set/setDate/setTime need refactoring to have single concerns
// (set: set the value; setDate/setTime rename to renderDate/renderTime
// and deal with updating the view only).
// For now this allows us to set the default time using the same quantize
// rules as setting the date explicitly. Setting this.value meets setTime|Date's
// expectation that we have a value, and `0` guarantees that we will detect
this.value = moment(0);
this.setDate(this.options.default);
this.setTime(this.options.default);
} else {
this.setDate(this.value);
this.setTime(this.value);
}
To 至
if (!this.value) {
// TODO hack
// set/setDate/setTime need refactoring to have single concerns
// (set: set the value; setDate/setTime rename to renderDate/renderTime
// and deal with updating the view only).
// For now this allows us to set the default time using the same quantize
// rules as setting the date explicitly. Setting this.value meets setTime|Date's
// expectation that we have a value, and `0` guarantees that we will detect
this.value = moment(0);
this.setDate("12/12/1992");
this.setTime(this.options.default);
} else {
this.setDate(this.value);
this.setTime(this.value);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.