Evo_x Evo_x - 1 year ago 133
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.

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download