Please tell me how to use the datepicker of monaca.

Asked 2 years ago, Updated 2 years ago, 60 views

Datepicker Plug-in - Monaca Documentation

"By looking at the above page, I have reached the point where I can enable the ""datepicker"" Cordova plug-in for monaca."

However, I don't know where and what to write after that.
Sorry for the rudimentary question...

If it is different from Android and iOS,
It may not work to write in the common index.html.

However, html has not been generated in either Android folder or iOS folder, so
I don't know where to write it.

"Also, if possible, I would like to do ""Subtract the specified date from today's date"" after this problem is resolved."I would appreciate it if you could give me some advice about that.

Sorry for the inconvenience, but I look forward to hearing from you.

html monaca cordova

2022-09-30 20:34

1 Answers

If you write it in index.html, it will be fine.You can use the properties monaca.isAndroid and monaca.isIos to separate them by operating system as shown below.

<!DOCTYPE HTML>
<html>
<head>
    <metacharset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scale=no">
    <script src="components/loader.js"></script>
    <link rel="stylesheet" href="components/loader.css">
    <link rel="stylesheet" href="css/style.css">
    <script>

      function dateTest(){

        if(monaca.isAndroid===true){

            var myNewDate = newDate();

            window.plugins.datePicker.show({
                date —myNewDate,
                mode: 'date',
                allowOldDates—true
            }, function(returnDate){
                var newDate = newDate(returnDate);
                alert(newDate.toString());
            });

        } else{
            vardatePicker=window.plugins.datePicker;
            datePicker.show({
                "mode": "datetime",
                "date" : new Date("2000/01/02 03:04:05")
            }, function(date){
                alert(new Date(date).toString())
            });
        }
    }    

    </script>
</head>
<body>
    <br of >
    <button onclick="dateTest()">Test</button>
</body>
</html>

"Also, if possible, I would like to process ""subtract the specified date from today's date"" after solving this problem."I would appreciate it if you could give me some advice on that as well

Date objects have functions such as getHours(), which can be combined to obtain time, etc.Learn more about MDN here.

https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Date


2022-09-30 20:34

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.