× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

AngularJS get formatted date in ng-model

Jul 21, 2015
<p>You can try a filter</p> <p>HTML</p> <pre><code>&lt;input type="datetime" ng-model="mydateOfBirth" class="form-control" id="date_of_birth" /&gt; </code></pre> <p>Controller JS </p> <pre><code>$scope.$watch('mydateOfBirth', function (newValue) { $scope.workerDetail.dateOfBirth = $filter('date')(newValue, 'YYYY/MM/DD'); }); $scope.$watch('workerDetail.dateOfBirth', function (newValue) { $scope.mydateOfBirth = $filter('date')(newValue, 'YYYY/MM/DD'); }); </code></pre> <p>This tip was originally posted on <a href="http://stackoverflow.com/questions/26486696/AngularJS%20get%20formatted%20date%20in%20ng-model/26486817">Stack Overflow</a>.</p>

Get New Tutorials Delivered to Your Inbox

New tutorials will be sent to your Inbox once a week.

comments powered by Disqus