Giter Site home page Giter Site logo

Comments (15)

Yuripetusko avatar Yuripetusko commented on August 14, 2024 14

This is my solution in coffeescript that works both on iOS and Android
maxDate = if ionic.Platform.isIOS() then new Date() else (new Date()).valueOf()

from cordova-plugin-datepicker.

fdlk avatar fdlk commented on August 14, 2024 2

This is the sort of thing that cordova is supposed to shield the user from. It should be consistent across both platforms.

from cordova-plugin-datepicker.

hirbod avatar hirbod commented on August 14, 2024 1

Someone should mention this inside of the documents. @VitaliiBlagodir

from cordova-plugin-datepicker.

hirbod avatar hirbod commented on August 14, 2024

I can confirm, min and maxdate won't work on Android, but on iOS. I use moment.js to generate a specific JS-Date-Object.

            $scope.minDate =  moment().locale('de').subtract(90, 'years').toDate();
            $scope.maxDate =  moment().locale('de').subtract(13, 'years').toDate();

            var options = {
                date: new Date(),
                doneButtonLabel: $scope.trans.SET,
                cancelButtonLabel: $scope.trans.CLOSE,
                doneButtonColor: '#f39200',
                cancelButtonColor: '#000',
                minDate: $scope.minDate,
                maxDate: $scope.maxDate,
                mode: 'date'
            };

from cordova-plugin-datepicker.

harikrishnan992 avatar harikrishnan992 commented on August 14, 2024

Thank you for your support. Let me try this solution

-----Original Message-----
From: "Hirbod" [email protected]
Sent: ‎25-‎02-‎2015 08:42 AM
To: "VitaliiBlagodir/cordova-plugin-datepicker" [email protected]
Cc: "harikrishnan992" [email protected]
Subject: Re: [cordova-plugin-datepicker] minDate and MaxDate not working (#60)

I can confirm, min and maxdate won't work on Android, but on iOS. I use moment.js to generate a specific JS-Date-Object.
$scope.minDate = moment().locale('de').subtract(90, 'years').toDate();
$scope.maxDate = moment().locale('de').subtract(13, 'years').toDate();

        var options = {
            date: new Date(),
            doneButtonLabel: $scope.trans.SET,
            cancelButtonLabel: $scope.trans.CLOSE,
            doneButtonColor: '#f39200',
            cancelButtonColor: '#000',
            minDate: $scope.minDate,
            maxDate: $scope.maxDate,
            mode: 'date'
        };


Reply to this email directly or view it on GitHub.

from cordova-plugin-datepicker.

hirbod avatar hirbod commented on August 14, 2024

There is no solution. Just confirmed your bug

from cordova-plugin-datepicker.

hirbod avatar hirbod commented on August 14, 2024

@VitaliiBlagodir anny suggestion why min and maxdate are broken on Android, while they work fine on iOS?

from cordova-plugin-datepicker.

Yuripetusko avatar Yuripetusko commented on August 14, 2024

maxDate and minDate work on Android for me if I do Date.parse(new Date()) or (new Date()).valueOf() but not on iOS

from cordova-plugin-datepicker.

hirbod avatar hirbod commented on August 14, 2024

Thanks for your input @Yuripetusko, this is at least a good way to provide a fallback! Thank you very much. I've just installed Cordovas Device Plugin to check the system. Not really happy with that overhead, but at least, it works fine!

from cordova-plugin-datepicker.

hirbod avatar hirbod commented on August 14, 2024

I use OnsenUI, but they also have a platform detection. Thanks for the hint!

from cordova-plugin-datepicker.

code2be avatar code2be commented on August 14, 2024

Thanks @Yuripetusko, Your hint worked for me !
Used device.platform to check for OS being iOS or Android.

from cordova-plugin-datepicker.

slj avatar slj commented on August 14, 2024

As identified here:

http://forum.ionicframework.com/t/ngcordova-datepicker-show-twice/16158/11

minDate is a Date object for iOS and an integer for Android, so you need to account for that when using the plugin. For example, with Ionic Framework, do something like this:

minDate = ionic.Platform.isIOS() ? new Date() : (new Date()).valueOf();

datePickerOptions = {
  date: new Date(),
  minDate: minDate,
  mode: 'date'
};

from cordova-plugin-datepicker.

thuey avatar thuey commented on August 14, 2024

While updating the documentation, can you change "integer" to "millisecond precision unix timestamp"? I was struggling until I found this issue because I was using second precision unix timestamps.

from cordova-plugin-datepicker.

jenkinssgs avatar jenkinssgs commented on August 14, 2024

How to format the date from "Mon Mar 04 2019" to "03/04/2019".Thanks.

from cordova-plugin-datepicker.

svashisth07 avatar svashisth07 commented on August 14, 2024

@jenkinssgs moment("Mon Mar 04 2019").format("MM/DD/YYYY")

from cordova-plugin-datepicker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.