<!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> <button type="button" onclick="showTime();">获取时间 </button> </div> </div> </body> <script type="text/javascript"> function showDate(){ var dDate = new Date(); dDate.setFullYear(2018,3,8); var minDate = new Date(); minDate.setFullYear(2010,1,1); var maxDate = new Date(); maxDate.setFullYear(2020,12,31); plus.nativeUI.pickDate( function(e){ var d = e.date; mui.toast('您选择的日期是:'+d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate()); }, function(e){ mui.toast('您没有选择'); }, { title:'请选择日期', date:dDate, minDate:minDate, maxDate:maxDate } ); } function showTime(){ var myDate = new Date(); var h = myDate.getHours(); var min = myDate.getMinutes(); var dTime = new Date(); 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> </html>