Original Address: http: //www.hcoder.net/tutorials/info_86.html
Complete code:
<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">hello</h1> </header> <div class="mui-content"> <div style="padding:15px;"> <button id='pickDateBtn' type="button" class="mui-btn">选择日期</button> </div> <div style="padding:15px;"> <button id='pickTimeBtn' type="button" class="mui-btn">选择时间</button> </div> </div> <script type="text/javascript"> document.getElementById("pickDateBtn").addEventListener('tap', function() { var dDate = new Date(); // Set the current date (the default setting is not the current date) dDate.setFullYear (2016,. 7, 16 ); var the minDate = new new a Date (); // minimum time minDate.setFullYear (2010, 0,. 1 ); var the maxDate = new new dATE (); // maximum time maxDate.setFullYear (2016,. 11, 31 is ); plus.nativeUI.pickDate ( function (E) { var D = e.date; mui.toast ( 'date of your choice is:' + d.getFullYear () + "-" + (d.getMonth () +. 1) + "-" + d.getDate ()); }, function (E) { mui.toast ("You did not select date" ); }, { title: 'Please select a date' , DATE: dDate, the minDate: the minDate, the maxDate: the maxDate }); }); document.getElementById ( "pickTimeBtn") the addEventListener ( 'TAP'. , function () { var dTime = new new a Date (); // set default time dTime.setHours (. 6, 0 ); plus.nativeUI.pickTime ( function (E) { var D = e.date; mui.toast ( " You choose the time: "+ d.getHours () +": "+ d.getMinutes ()); },function (E) { mui.toast ( "you did not select time" ); }, { title: "Choose Time" , is24Hour: to true , Time: dTime }); });
js get the current time
var myDate = new new a Date (); myDate.getYear (); // get the current year (2) myDate.getFullYear (); // get the full year (4, 1970 - ????) myDate.getMonth ( ); // get the current month (0-11,0 behalf January) myDate.getDate (); // get the current day (1-31) myDate.getDay (); // get the current week X (0-6, 0 for Sunday) myDate.getTime (); // get the current time (number of milliseconds from the start 1970.1.1) myDate.getHours (); // get the number (0-23) current hour myDate.getMinutes (); // Gets the current number (0-59) minutes myDate.getSeconds (); // get the current number of seconds (0-59) myDate.getMilliseconds (); // get the current number (0-999) milliseconds myDate.toLocaleDateString (); // get the current date var MyTime myDate.toLocaleTimeString = (); // get the current time myDate.toLocaleString (); // get the date and time