Input datetime-local does not take min attribute

1

I'm taking an input type datetime-local with angularjs and from the controller I get today's date and add one more day and I would like that date to be the minimum date of my input so the user can not choose a lower date to this.

<input type="datetime-local" min="{{fecha_minima.value}}" ng-model="fecha_minima.value">

And in my controller

$scope.fecha_minima = new Date();
$scope.fecha_minima = {
    value : new Date($scope.fecha_minima.getFullYear(),  $scope.fecha_minima.getMonth(),  $scope.fecha_minima.getDate()+1, $scope.fecha_minima.getHours(), $scope.fecha_minima.getMinutes())
};

However this does not work, it allows me to choose dates lower than the one I give, but if I put in the attribute min a specific date this works, for example min="2016-11-21T00:00:00" the calendar blocks the previous days.

    
asked by sioesi 21.11.2016 в 16:18
source

1 answer

1

Pass the date to this function and it will return the format you need for the min of the input type datetime-local . It would be something like formatToDateTimeLocal(new Date()) :

function formatToDateTimeLocal (date){
        var isoDate = date.toISOString();
        return isoDate.split(".")[0];
}
    
answered by 22.11.2016 / 08:44
source