Open In App
Related Articles

AngularJS angular.isDate() Function

Improve Article
Improve
Save Article
Save
Like Article
Like

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:

 


Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 06 Sep, 2022
Like Article
Save Article
Previous
Next
Similar Reads
Complete Tutorials