Evo_x Evo_x - 7 months ago 43
AngularJS Question

Angularjs - display current date

I got a view in angularjs and I'm just trying to display the current date(formatted). I thought something like

<span>{{Date.now() | date:'yyyy-MM-dd'}}</span>
should display the current date.


You have to create a date object in your controller first:


function Ctrl($scope)
    $scope.date = new Date();


<div ng-app ng-controller="Ctrl">
    {{date | date:'yyyy-MM-dd'}}

JSFiddle example

Angular Date Filter Ref