In Angular Material md-datepicker, when I click on date picker it sets the system's current date as today's date. We notice that today's date is circled in the date picker's calendar. I want to know if there is a way to set any given date as today's date. Please refer this image. md-datepicker's calender (today's date highlighted in Yellow)
So, in my case, if I set today's date as 2nd April 2017, the datepicker should set this as today's date and circle this date on the calendar
In Angular Material md-datepicker, when I click on date picker it sets the system's current date as today's date. We notice that today's date is circled in the date picker's calendar. I want to know if there is a way to set any given date as today's date. Please refer this image. md-datepicker's calender (today's date highlighted in Yellow)
So, in my case, if I set today's date as 2nd April 2017, the datepicker should set this as today's date and circle this date on the calendar
Share Improve this question asked Mar 4, 2017 at 9:53 Sameer ShaikSameer Shaik 1671 gold badge3 silver badges12 bronze badges 1- You can use <md-datepicker ng-model="ctrl.myDate" md-placeholder="Enter date"></md-datepicker> and in you controller this.myDate = new Date('2017-04-17T03:24:00'); – Dhananjay Sakhare Commented Mar 4, 2017 at 10:31
1 Answer
Reset to default 3HTML
<md-content ng-controller="AppCtrl as ctrl" layout-padding="" ng-cloak="" class="datepickerdemoBasicUsage" ng-app="MyApp">
<div layout-gt-xs="row">
<div flex-gt-xs="">
<h4>Standard date-picker</h4>
<md-datepicker ng-model="ctrl.myDate" md-placeholder="Enter date"></md-datepicker>
</div>
</md-content>
JS
angular.module('MyApp',['ngMaterial', 'ngMessages', 'material.svgAssetsCache']).controller('AppCtrl', function() {
this.myDate = new Date('2017-04-17T03:24:00');
this.isOpen = false;
});
this.myDate = new Date('2017-04-17T03:24:00');
You can set your own date here. In your case you wanted 2nd April 2017 as default date in datetime picker then you should write
this.myDate = new Date('2017-04-01T03:24:00');
Live Demo
I referred Angular Material website for this