Do you choose which third-party date selection control to use when you develop WebApp?
In fact, not so troublesome, now mobile is WebKit kernel, support HTML5, in fact, as long as the weak weak will input type= "date" OK, the operating system will automatically recognize as the date type and call the system comes with the date selection. Don't worry about the style of the date control is not uniform, because who cares? O (╯-╰) O, everyone is staring at their cell phones, who choose a date to compare other mobile phones?
Recently saw a better date choose Plug-in mobiscroll, online word-of-mouth is particularly good, I also downloaded to play a bit, the reason is not entirely because he high imitation iOS and Android date selection style, but his price incredibly up to more than 800 $, good expensive Ah, And look at the table of contents: 5 CSS files, 7 JS files, so many people, when the user's traffic is not money?
The following describes how to use the date control that comes with HTML
Html:
1 < ID= "start_time" name= "start_time" type= "date" Class= "Form-control"/>
Js:
1 $ (' #start_time '). Val (new Date ()); // set the current date as the default value for the control
Of course, there are some children's shoes that will ask me, it is the date type, its value may be Fri Apr 15:15:00 gmt+0800 (China Standard Time), this heap of things how to save the database ah, can not be converted to the type of string I need to format, of course!
Js:
1 //date formatting Formatstr:yyyy-mm-dd2Date.prototype.Format =function(FORMATSTR)3 { 4 varstr =Formatstr; 5 varWeek = [' Day ', ' one ', ' two ', ' three ', ' four ', ' five ', ' six ']; 6 varMonth= This. GetMonth () +1;7Str=str.replace (/yyyy| yyyy/, This. getFullYear ()); 8Str=str.replace (/yy| yy/, ( This. GetYear ()%) >9? ( This. GetYear ()%). ToString (): ' 0 ' + ( This. GetYear ()% 100)); 9Str=str.replace (/mm/,month>9?month.tostring (): ' 0 ' +month); TenStr=str.replace (/m/g,month); OneStr=str.replace (/w| w/g,week[ This. GetDay ()]); AStr=str.replace (/dd| Dd/, This. GetDate () >9? This. GetDate (). toString (): ' 0 ' + This. GetDate ()); -Str=str.replace (/d| D/g, This. GetDate ()); -Str=str.replace (/hh| hh/, This. getHours () >9? This. GetHours (). toString (): ' 0 ' + This. GetHours ()); theStr=str.replace (/h| H/g, This. GetHours ()); -Str=str.replace (/mm/, This. getminutes () >9? This. getminutes (). toString (): ' 0 ' + This. getminutes ()); -Str=str.replace (/m/g, This. getminutes ()); -Str=str.replace (/ss| ss/, This. getseconds () >9? This. getseconds (). toString (): ' 0 ' + This. getseconds ()); +Str=str.replace (/s| S/g, This. getseconds ()); - returnstr; + } A at$ (' #start_time '). Val (NewDate (). Format ("Yyyy-mm-dd"));//Yyyy/mm/dd, you can do it with a separate number.
Summarize:
Technology updates to our developers are beneficial should try, especially in mobile can fully play the potential of HTML5, do not follow the rules of the use of third-party components, mobile performance like a small doll, can not stand storms, we have to take advantage of HTML5 for our developers to simplify the work and provide the label properties, As little as possible to load JS and other third-party components.
Date selection in the WebApp