Skip to content
Advertisement

Angular 2 Ionic 2 – How to set max or min date to today for date input?

JavaScript

How can I set the max date for today instead of 2018-03-07 dynamically?

I tried following methods-

JavaScript

Class –

JavaScript

but no luck.

Advertisement

Answer

Try this:

JavaScript

Working Example Demo

Reason:

Because when you are using new Date() this will give you full date with time zone and time etc, you have to assign only Date so you have to split this with only Date. For more clarification run this:

JavaScript
Advertisement