Skip to content Skip to sidebar Skip to footer

How To Set Today Date And Time As Default In Angular-moment-picker

I am using angular-moment-picker input for datetimepicker, and I want to set today date and current time on the input. Here is my source code. can you please help me. Thank you &l

Solution 1:

set default value startDate when controller initialized

angular
  .module('Demo', ['moment-picker'])
  .controller('DemoController', ['$scope', function ($scope) {

      $scope.startDate = moment();
  }]);

Solution 2:

Use moment() method in script file.

http://embed.plnkr.co/GqJMbeQ5UtSbIutn8elf/

Solution 3:

You can set start date by using the start-date attribute in your input control. The value should be an moment object.

<inputclass="form-control"format="DD/MM/YYYY HH:mm"
    ng-model-options="{ updateOn: 'blur' }"
    moment-picker="startDate"id="startDate"
    ng-model="startDate"
    start-date="startDate">

Here is the working fiddle. Here I have used moment and angular-moment library and module respectively

Post a Comment for "How To Set Today Date And Time As Default In Angular-moment-picker"