Prev Demo
AngularJS
>
Date Formatting
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script> </head> <body> <script> var app = angular.module("app", []); app.controller("DateController", ["$scope", function ($scope) { $scope.ThisDate = new Date(); }]); </script> <h2>Date time formatting in AngularJS</h2> <div ng-app="app" ng-controller="DateController"> <div> <table class="table"> <tr> <th>Demo Date time</th> <th colspan="2">{{ThisDate}}</th> </tr> <tr> <td>yyyy: </td> <td>{{ ThisDate | date: 'yyyy'}} </td> <td>4 digit year</td> </tr> </table> </div> </div> </body> </html>
Note: We DO NOT save your trial code in our database.
Output