2

I am trying to add Native Date picker in my project and the plugin is below,

1st pulgin:

cordova plugin add https://github.com/DURK/cordova-datepicker-plugin

(or) 2st plugin:

cordova local plugin add https://github.com/VitaliiBlagodir/cordova-plugin-datepicker

The 2-plugins are working well and i want to set maxDate and minDate for that Datepicker. But, i can't get any solution for that.

Give any suggestion for that. Thank you.

Satyam Koyani
  • 4,236
  • 2
  • 22
  • 48
san
  • 214
  • 1
  • 10

2 Answers2

2

VitaliiBlagodir-cordova-plugin-datepicker supports setting of maxDate and minDate.

It is supported in iOS and android.

Documentation suggests that

minDate is a Date object for iOS and an integer for Android, so you need to account for that when using the plugin.

minDate and maxDate must be DATE objects for iOS,

Both attributes should be integer for android. so need to parse Date object with

Date.parse(new Date()) or (new Date()).valueOf()

Satyam Koyani
  • 4,236
  • 2
  • 22
  • 48
0
     import { Platform } from 'ionic-angular';
     constructor(private platform: Platform) {}

at date picker show method

     maxDate = (this.platform.is('android')) ? (new Date(endtime)).valueOf() : new Date(endtime)
Thisara Sudaraka
  • 531
  • 1
  • 4
  • 9