angularJS set today to input date
$scope.value = new Date().toISOString().split("T")[0]; // 2014-05-23
tested in chrome.
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, 2022Comments
-
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 about 7 yearshow i can get Indian time zone date