AngularJS angular.isDate() Function
Last Updated :
06 Sep, 2022
Improve
The angular.isDate() function in AngularJS is used to determine whether the value of the date is valid or not. It returns true if the reference is a date else false.
Syntax:
angular.isDate( value );
Parameters: This function accepts a single parameter:
- value: It stores the data object.
Return Value: It returns true if the value passed is a date else return false.
Example 1: This example uses angular.isDate() function to determine the value of the date is valid or not.
HTML
<!DOCTYPE html> < html > < head > < title >angular.isDate() function</ title > < script src = "//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js" > </ script > </ head > < body ng-app = "app" style = "text-align:center" > < h1 style = "color:green" >GeeksforGeeks</ h1 > < h2 >angular.isDate()</ h2 > < div ng-controller = "geek" > < b >Date:</ b > {{ date }}< br > < br > isDate: {{isDate}} </ div > < script > var app = angular.module("app", []); app.controller('geek', ['$scope', function($scope) { $scope.date = new Date; $scope.isDate = angular.isDate($scope.date) }]); </ script > </ body > </ html > |
Output:

Example 2: This example uses angular.isDate() function in AngularJS by specifying the different date format..
HTML
<!DOCTYPE html> < html > < head > < title >angular.isDate() function</ title > < script src = "//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js" > </ script > </ head > < body ng-app = "app" style = "text-align: center" > < h1 style = "color: green" >GeeksforGeeks</ h1 > < h2 >angular.isDate()</ h2 > < div ng-controller = "geek" > < b >Date:</ b > {{ date | date : " MMM dd, yyyy, hh:mm:ss "}} < br />< br /> isDate: {{isDate}} </ div > < script > var app = angular.module('app', []); app.controller('geek', ['$scope', function($scope) { $scope.date = new Date(); $scope.isDate = angular.isDate($scope.date); }, ]); </ script > </ body > </ html > |
Output:
