Need Help Getting a DatePicker working, Please and thanks!


#1

Hey guys,

I need to get a datepicker working and then use the date to do some math (determine how far away it is, and so on).

Coming from a web development background my first instinct was <input type="date"> but my research showed this doesn’t work on all android devices, and that its device specific not android verions specific… example: Samsung Galaxy S2 on Android 4.0.3 does support it, but the Google/Samsung Nexus S on the more recent Android 4.0.4 does not.

So I started looking at plugins and found this one https://github.com/VitaliiBlagodir/cordova-plugin-datepicker and installed it successfully using the cordova CLI but can’t get the datepicker to work…

using this code to try and initializing it…

 /**
     * Function to show the date picker
     */
    $scope.showDatePicker = function($event) {
        var options = {
            date: new Date(),
            mode: 'date'
        };
        datePicker.show(options, function(date){
            if(date != 'Invalid Date') {
                console.log("Date came" + date);
            } else {
                console.log(date);
            }
        });
        $event.stopPropagation();  
    }; 

but failing to do so… am i missing something big here?

any help would be great, I’ve spent several days trying multiple plugins and various trouble shooting methods with no luck.


#2

Take a look at this post: http://forum.ionicframework.com/t/calendar-control-for-ionic/1536

And for calculation I use this two libraries:
-https://github.com/tdd/moments-away
-http://momentjs.com/


#3

thanks, I did not know about moments. will give it a look through.

ended up just doing the datepicker a very dirty angular way without a plugin as if it was just a website. it works, and thats farther than I got all week.

thanks again for your help!


#4

Hi @BioPerl, I have created both time picker and date picker for ionic frame works.
No additional dependencies like jQuery is not required. Hope this might help you. Please have a look at the below links.

ionic-timepicker demo

ionic-timepicker Bower component

ionic-datepicker demo

ionic-datepicker Bower component


#5

Hi Rajesh
I tried out your date pickerand like it a lot. I was wondering if you had a plugin that combined both tools into one. datetime picker.

Thanks for the great lib.


#6

These two are two different plugins for now. You need to install the two plugins separately.