Angularjs - display current date
You have to create a date object in your controller first:
controller:
function Ctrl($scope)
{
$scope.date = new Date();
}
view:
<div ng-app ng-controller="Ctrl">
{{date | date:'yyyy-MM-dd'}}
</div>
JSFiddle example
Angular Date Filter Ref
You can also do this with a filter if you don't want to have to attach a date object to the current scope every time you want to print the date:
.filter('currentdate',['$filter', function($filter) {
return function() {
return $filter('date')(new Date(), 'yyyy-MM-dd');
};
}])
and then in your view:
<div ng-app="myApp">
<div>{{'' | currentdate}}</div>
</div>