jquery make a date choice for mobile phone side

Source: Internet
Author: User
Tags button type

The first step: Make a text box to display the date of the month

Step Two: Click on the text box to trigger the bootstrap modal box and display

Step three: I am building an external JS page to write

JS to get the current time is the year and month, shape: 201208

Get the full date
var date=new date;
var year=date.getfullyear ();
var month=date.getmonth () +1;
Month = (month<10? "0" +month:month);
var mydate = (year.tostring () +month.tostring ());

Note that year.tostring () +month.tostring () cannot be written as Year+month. Otherwise, if the month is greater than or equal to 10, the month is a number, and the year is added, such as 201210, will become 2022, need to add. toString ()


Here are some useful things to search for:

var mydate = new Date ();
Mydate.getyear ();Get Current year (2-bit)
Mydate.getfullyear ();Get the full year (4-bit, 1970-????)
Mydate.getmonth ();Get the current month (0-11, 0 for January)
Mydate.getdate (); //Get current day (1-31)
Mydate.getday (); //Get Current week x (0-6, 0 for Sunday)
Mydate.gettime (); //Gets the current time (number of milliseconds since 1970.1.1)
Mydate.gethours (); //Get current hours (0-23)
Mydate.getminutes (); //Gets the current number of minutes (0-59)
Mydate.getseconds (); //Gets the current number of seconds (0-59)
Mydate.getmilliseconds (); //Gets the current number of milliseconds (0-999)
Mydate.tolocaledatestring (); //Get the current date
var mytime=mydate.tolocaletimestring (); //Get current time
Mydate.tolocalestring (); //Get date and time

<script language= "JavaScript" >
function Monthnow () {
var now = new Date ();
var monthn = Now.getmonth ();
var yearn = now.getyear ();
window.location.href= "winnnamelist.jsp?getmonth=" +monthn+ "&getyear=" +yearn;
}
</script>

PHP page

<!doctype html>

 js page below

JavaScript document//Add an event to the month to put the above $ (Document). Ready (function (e) {//The selected item of the current year changes to the number of days from the new selection of $ ("#nian"). Change (Function ( ) {Loadtian ();}) $ ("#yue"). Change (function () {///when the drop-down of the month is changed to the next number of days Loadtian ();})}); /Load Year function Loadnian () {var date=new date; var year=date.getfullyear ();//get current year var str = ""; for (Var i=year-5;i<year +6;i++)//minus 5 from the current year, plus 6 for the current year, 5 years after the first 5 years//i is equal to the year {if (i==year)//default location current year {str + = "<option selected= ' selected ' value= '" +i+ " > "+i+" </option> "///default positioning current year}else{str + =" <option value= ' "+i+" ' > "+i+" </option> ";} $ ("#nian"). html (str);//Find the drop-down ID equals Nian to throw the option inside, option equals str}//load Month function Loadyue () {var date=new date; var yue= Date.getmonth () +1;var str = ""; for (var i=1;i<13;i++) {if (I==yue)//Current Month {str + = "<option selected= ' selected ' value= ' "+i+" > "+i+" </option> ";} Else{str + = "<option value= '" +i+ ">" +i+ "</option>";}} $ ("#yue"). html (str);} Load days function Loadtian () {var date=new date;var Tian = date.getdate ();//Get current day var zs = 31;//Total days var Nian = $ ("#nian"). Val ();//Take the current selected year var Yue = $ ("#yue"). Val ();//Take the currently selected month if (Yue = = 4 | | yue==6 | | yue==9 | | yue==11)//Determine what case does not equal 31, there are 2 conditions one is the year one is the month | | Or when the month equals 4,6,9,11 equals 30 days {ZS = 30;} else if (yue==2)//If it is February {if (nian%4==0 && nian%100!=0) | | nian%400==0)//The general year condition can be divisible by 4 and not divisible by 100. Or can be divisible by 400 is the run year {ZS = 29;} Else{zs = 28;}} var str = ""; for (var i=1;i<zs+1;i++) {if (I==tian) {str + = "<option selected= ' selected ' value= '" +i+ ">" +i+ "</ Option> ";} Else{str + = "<option value= '" +i+ ">" +i+ "</option>";}} $ ("#tian"). html (str);}

jquery make a date choice for mobile phone side

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.