Mui-获取日期和时间-调用手机api

<!DOCTYPE html>
<html>

    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
        <title></title>
        <script src="js/mui.min.js"></script>
        <link href="css/mui.min.css" rel="stylesheet" />
        <script type="text/javascript" charset="utf-8">
            mui.init();
        </script>

    </head>

    <body>
        <header class="mui-bar mui-bar-nav">
            <!--顶部导航栏-带返回键-->
            <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
            <h1 class="mui-title">测试属性</h1>
        </header>
        <div class="mui-content">
            <div style="padding: 20px;">
                <button type="button" onclick="showDate();">获取日期</button>
            </div>
        </div>
        <script type="text/javascript">
            function showDate(){
                var dDate = new Date();/*获取手机的当前日期*/
                dDate.setFullYear(2019,6,23);/*默认选中设置日期格式*/
                var minDate = new Date();/*获取最小日期*/
                minDate.setFullYear(2010,1,1);
                var maxDate = new Date();
                maxDate.setFullYear(2119,6,23);
                
                plus.nativeUI.pickDate(
                    function(e){
                        var d = e.data;
                        mui.toast(您选择的日期是: + d.getFullYear() + "-" + (d.getMonth()+1) + "-" +d.getData());
                    },
                    function(e){
                        mui.toast(您没有的选择日期);
                    },
                    {
                        title:请选择日期,
                        date:dDate,
                        minDate:minDate,
                        maxDate:maxDate
                    }
                );
            }
            
        </script>
    </body>

</html>

 ---获取手机当前时间

<!DOCTYPE html>
<html>

    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
        <title></title>
        <script src="js/mui.min.js"></script>
        <link href="css/mui.min.css" rel="stylesheet" />
        <script type="text/javascript" charset="utf-8">
            mui.init();
        </script>

    </head>

    <body>
        <header class="mui-bar mui-bar-nav">
            <!--顶部导航栏-带返回键-->
            <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
            <h1 class="mui-title">测试属性</h1>
        </header>
        <div class="mui-content">
            <div style="padding: 20px;">
                <button type="button" onclick="showDate();">获取时间</button>
            </div>
        </div>
        <script type="text/javascript">
            function showDate(){
                var myDate = new Date();
                var h = myDate.getHours();
                var min = myDate.getMinutes();
                var dTime = new Date();
                /*dTime.setHours(6,0);设置的固定时间*/
                dTime.setHours(h,min);
                /*呼出系统时间选择器*/
            plus.nativeUI.pickTime(function(e){
                var d = e.date;
                mui.toast("您选择的时间是:" + d.getHours() + ":" + d.getMinutes());
            },function(e){
                mui.toast("您没有选择时间");
            },{
                title: "请选择时间",
                is24Hour: true,
                time: dTime/*默认当前时间*/
            });
            }
            
        </script>
    </body>

</html>

 

Mui-获取日期和时间-调用手机api

上一篇:棋子移动 1295


下一篇:开发原生安卓cordova插件(有原生界面)