angularJS set today to input date

13,273
$scope.value = new Date().toISOString().split("T")[0]; // 2014-05-23

tested in chrome.

Share:
13,273
Albert Prats
Author by

Albert Prats

Working as a Web developer and studying Computer engineering at UPC (Barcelona) experience in HTML, CSS, Javascript, Jquery, PHP, Backbone.js, AngularJS, SQL, C++, C# and more things i dont remember. Bulding WebApps.

Updated on June 30, 2022

Comments

  • Albert Prats
    Albert Prats almost 2 years

    I had been trying to set the date to a input type="date" using angular's ng-model and value with no success. I tryed to use the documentation of angular JS about the input-date and the only thing I got was to set the year of the input, day and month remained with the placeholder value: "dd/mm/2014".

    what I tried:

    $scope.value = new Date(2013, 9, 22);
    

    and in my HTML:

    <input type="date" id="exampleInput" name="input" ng-model="value" placeholder="yyyy-MM-dd" min="2013-01-01" max="2013-12-31" required />
    

    and what I get is tha input date with: "dd/mm/2013"

    I tried using the angular documentation example to be sure that I am doing it right, thats because of the min and max value of the date.

    Any idea on how to fill my input date with the date of today ?

    Thanks in advance

  • Satish Kumar sonker
    Satish Kumar sonker about 7 years
    how i can get Indian time zone date