0

How to check using AngularJS if date existed before like February 29 2014?

Because separately February 29 is valid date, but February 29 2014 did not exist.

For example I am trying to use angular.isDate():

var date = new Date(2014, 02, 29);
var isValidDate = angular.isDate(date);

JavaScript still creates Date Object: March 01 2014, because February 29 2014 did not exist and that is and angular.isDate() returns true

Renat Gatin
  • 6,053
  • 5
  • 37
  • 58

1 Answers1

0

angular.isDate() just does a simple check of the type of the object you pass to it.

You have to check if it is a valid date before calling Date: See here how to do this

Community
  • 1
  • 1
Frederik H
  • 1,406
  • 2
  • 13
  • 15