10 examples of 'how to set current date in datepicker using javascript' in JavaScript

Every line of 'how to set current date in datepicker using javascript' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
18function updateDatePicker() {
19
20 var startMonth = new Date();
21
22 $("#dpStart").datepicker("option", "dateFormat", "yy-mm-dd");
23 $("#dpStart").datepicker("setDate", startMonth);
24}
60function setDatePicker(){
61 var dates = $( "#f1, #f2" ).datepicker({
62 changeMonth: true,
63 changeYear: true,
64 numberOfMonths: 1,
65 dateFormat: "dd.mm.yy",
66 minDate: "01.01."+times[currentLevel+1][firstBar][1],
67 maxDate: "31.12."+times[currentLevel+1][lastBar][1],
68 //beforeShow: function(input, inst) {
69 // $("#ui-datepicker-div").css("z-index", 100);
70 //},
71 onSelect: function( selectedDate ) {
72 var option = this.id == "f1" ? "minDate" : "maxDate",
73 instance = $( this ).data( "datepicker" ),
74 date = $.datepicker.parseDate(
75 instance.settings.dateFormat ||
76 $.datepicker._defaults.dateFormat,
77 selectedDate, instance.settings );
78 dates.not( this ).datepicker( "option", option, date );
79 }
80 });
81 $('#ui-datepicker-div').hide();
82}
84onDateChange(date) {
85 this.setState({date: date});
86}
64handleChange(date) {
65 if (!date) {
66 if (this.props.onChange) {
67 this.props.onChange(null, null, '');
68 }
69 return;
70 }
71 if (this.props.onChange) {
72 this.props.onChange(
73 date.toDate().toISOString(), // ISO 8601
74 date.format(this.props.dateFormat), // 使用moment.js按照用户指定的格式进行格式化
75 date
76 );
77 }
78}
31onDateChange(date: any): void {
32 // Update this react component state
33 this.setState({ date });
34
35 // Update angular component container state
36 this.ngComponent.value = date ? date.toDate() : null;
37}
22onChange(date) {
23 this.setState({
24 date,
25 });
26}
20function updateDatePicker() {
21
22 var searchType = $("#selSearchType").val();
23 if (searchType == "day") {
24
25 var endDay = new Date();
26 var startDay = new Date();
27 startDay.setMonth(endDay.getMonth()-1);
28
29 $("#dpStart").datepicker("option", "dateFormat", "yy-mm-dd");
30 $("#dpStart").datepicker("setDate", startDay);
31 $("#dpEnd").datepicker("option", "dateFormat", "yy-mm-dd");
32 $("#dpEnd").datepicker("setDate", endDay);
33
34 } else if (searchType == "month") {
35
36 var endMonth = new Date();
37 var startMonth = new Date();
38 startMonth.setFullYear(endMonth.getFullYear()-1);
39
40 $("#dpStart").datepicker("option", "dateFormat", "yy-mm");
41 $("#dpStart").datepicker("setDate", startMonth);
42 $("#dpEnd").datepicker("option", "dateFormat", "yy-mm");
43 $("#dpEnd").datepicker("setDate", endMonth);
44
45 }
46}
41update (date) {
42 date = new Date(DateManager.prettyDateFormat(date));
43 this.dayWheel.setDate(date.getDate() - 1);
44 this.monthWheel.setDate(date.getMonth());
45
46 const yearIdx = yearRange.indexOf(date.getFullYear());
47 this.yearWheel.setDate(yearIdx);
48}
114private set initDate(value:Date) {
115 this._initDate = value;
116}
21handleChange(date) {
22 if (typeof this.props.onChangeCallback === 'function') {
23 this.props.onChangeCallback({ date });
24 }
25}

Related snippets