js output lunar calendar, solar calendar, year, month, week sample code_javascript skills
The code is as follows:
js gets the time accurate to seconds (year, month, day)_javascript skills
The example in this article shares with you all the codes that use js to obtain time and output values for your reference and study. The specific content is as follows Implementation code: Rendering: Specific method: var myDate = new Date(); myDate.getYear(); //Get the current year (2 digits) myDate.getFullYear(); //Get the complete year (4 digits, 1970-????) myDate.getMonth(); //Get the current month (0-11, 0 represents January) myDate.getDate(); //Get the current day (1-31) myDate.getDay(); //Get the current week X (0-6, 0 represents Sunday) myDate.getTime(); //Get the current time (the number of milliseconds since 1970.1.1) myDate.getHours(); //Get the current hours (0-23) myDate.getMinutes(); //Get the current minutes (0-59) myDate.getSeconds(); //Get the current seconds (0-59) myDate.getMilliseconds(); //Get the current number of milliseconds (0-999) myDate.toLocaleDateString(); //Get the current date var mytime=myDate.toLocaleTimeString(); //Get the current time myDate.toLocaleString( ); //Get date and time I hope it will be helpful for everyone to learn Javascript programming.
JavaScript current date plus (day, week, month, year)_time and date
The code is as follows: //create the date var myDate = new Date (); //add a day to the date myDate.setDate(myDate.getDate() + 1); //add a week myDate.setDate (myDate.getDate() + 7); //add a month myDate.setMonth(myDate.getMonth() + 1); //add a year myDate.setYear(myDate.getYear() + 1);
js gets the time accurate to seconds (year, month, day)_javascript skills
The example in this article shares with you all the codes that use js to obtain time and output values for your reference and study. The specific content is as follows Implementation code: Rendering: Specific method: var myDate = new Date(); myDate.getYear(); //Get the current year (2 digits) myDate.getFullYear(); //Get the complete year (4 digits, 1970-????) myDate.getMonth(); //Get the current month (0-11, 0 represents January) myDate.getDate(); //Get the current day (1-31) myDate.getDay(); //Get the current week X (0-6, 0 represents Sunday) myDate.getTime(); //Get the current time (the number of milliseconds since 1970.1.1) myDate.getHours(); //Get the current hours (0-23) myDate.getMinutes(); //Get the current minutes (0-59) myDate.getSeconds(); //Get the current seconds (0-59) myDate.getMilliseconds(); //Get the current number of milliseconds (0-999) myDate.toLocaleDateString(); //Get the current date var mytime=myDate.toLocaleTimeString(); //Get the current time myDate.toLocaleString( ); //Get date and time I hope it will be helpful for everyone to learn Javascript programming.
Javascript implements calendar control (year, month, day close button)_javascript skills
Friends who often use Google must still remember Google’s gorgeous calendar control, so let’s implement one. Although the functions and effects are not comparable, the important thing is the implementation process. The following is to be implemented HTML structure: Year:Month: Let’s talk about the calendar query algorithm first: w=y+parseInt(y/4)+parseInt(c/4)-2*c+parseInt(26 *(m+1)/10)+d-1; The following is a detailed explanation process. If you are interested, you can read it: http://www.jb51.net/article/32572.htm The following is the implemented Javascript code: The code is as follows: sx.activex.calender={ bind:function(target){ var a=document.createElement(“p”); var head=document.createElement(“p”); var biaoti=document.createElement(“p”); var select=document.createElement(“select”); var yface=document. createElement(“span”); var mface=document.createElement(“span”); var body=document.createElement(“p”); var select1=document.createElement(“select” ); yface.appendChild(select); mface.appendChild(select1); head.appendChild(yface); head.appendChild(mface); a.appendChild(head ); a.appendChild(biaoti); a.appendChild(body); yface.insertBefore(document.createTextNode(“year”),yface.firstChild) mface.insertBefore(document .createTextNode(“month”),mface.firstChild) a.style.position=”absolute”; biaoti.style.height=”10%”; for(var i=0;i <7;i++){ var can=document.createElement(“span”) can.style.width=”14%”; can.style.height=”100%”; can.style.textAlign=”center”; biaoti.appendChild(can); } biaoti.all[0].innerText=”日” biaoti.all[1]. innerText=”one” biaoti.all[2].innerText=”two” biaoti.all[3].innerText=”three” biaoti.all[4].innerText=”four” biaoti.all[5].innerText=”five” biaoti.all[6].innerText=”six” head.style.height=”20%”; a.style .position=”absolute”; a.style.height=”200px”; a.style.width=”302px”; a.style.border=”1px red solid”; yface.style.width=”50%”; yface.style.padding=”5px”; yface.style.height=”100%”; select.style.width=”80 %”; for(var i=1960;i<2010;i++){ var option=document.createElement(“option”); option.text=i; select.add (option); } mface.style.width=”50%”; mface.style.padding=”5px”; mface.style.height=”100%”; select1.style.width=”80%”; for(var i=1;i<=12;i++){ var option=document.createElement(“option”); option .text=i; select1.add(option); } body.style.height=”70%”; for(var i=0;i<42;i++){ var span=document.createElement(“span”); span.style.width=”14%”; span.style.height=”16%”; span.style. textAlign=”center”; span.Onmouseover=function(){ this.style.cursor=”hand”; this.tempcolor=this.style.backgroundColor; this.style. backgroundColor=”lightblue”; } span.Onmouseout=function(){ this.style.backgroundColor=this.tempcolor; } span.Onclick=function(){ target.value=select.options[select.selectedIndex].text+”Year”+select1.options[select1.selectedIndex].text+”Month”+this.innerText+”Day”; a.parentNode.removeChild( a); } body.appendChild(span); } select.Onchange=function(){ for(var o in body.all){ body. all[o].innerText=””; if(o.toString()!=”length”) body.all[o].style.backgroundColor=””; } var year1=this.options[this.selectedIndex].text; var…
Two ways to display year, month, day, hour, minute, second and day of the week in html page_javascript skills
Js code The code is as follows: //—————————–method one—————– —————————- //——————————–Method 2——— ——————————–
js output lunar calendar, solar calendar, year, month, week sample code_javascript skills
The code is as follows:
JavaScript displays the natural date and time, namely year, month, day, week and time
Effect: Current time: Monday, June 20, 2011 12:0:19 The code is as follows: The code is as follows: Key places. </
Javascript implements calendar control (year, month, day close button)
Friends who often use Google must still remember Google’s gorgeous calendar control, so let’s implement one. Although the functions and effects are not comparable, the important thing is the implementation process. The following is to be implemented HTML structure: Year:Month: Let’s talk about the calendar query algorithm first: w=y+parseInt(y/4)+parseInt(c/4)-2*c+parseInt (26*(m+1)/10)+d-1; The following is a detailed explanation process. If you are interested, you can read it: https://www.jb51.net/article/32572 .htm The following is the implemented Javascript code: The code is as follows: sx.activex.calender={ bind:function(target){ var a=document.createElement(“div”); var head=document.createElement(“div”); var biaoti=document.createElement(” div”); var select=document.createElement(“select”); var yface=document.createElement(“span”); var mface=document.createElement(“span”); var body=document.createElement(“div”); var select1=document.createElement(“select”); yface.appendChild(select); mface.appendChild(select1); head.appendChild(yface); head.appendChild(mface); a.appendChild(head); a.appendChild(biaoti); a.appendChild(body); yface.insertBefore(document.createTextNode(“Year”),yface.firstChild) mface.insertBefore(document.createTextNode(“Month”),mface.firstChild) a.style.position=”absolute “; biaoti.style.; for(var i=0;i<7;i++){ var can=document.createElement(“span”) can.style.; can.style.; can.style.textAlign=”center”; biaoti.appendChild(can); } biaoti.all[0].innerText=”day” biaoti.all[1].innerText=”一” biaoti.all[2].innerText=”二” biaoti.all[3].innerText=”三” biaoti.all [4].innerText=”four” biaoti.all[5].innerText=”five” biaoti.all[6].innerText=”six” head.style.; a.style.position=”absolute”; a.style.; a.style.; a.style.border=”1px red solid”; yface.style.; yface.style.padding=”5px”; yface.style.; select.style.; for(var i=1960;i<2010;i++){ var option =document.createElement(“option”); option.text=i; select.add(option); } mface.style.; mface.style.padding= “5px”; mface.style.; select1.style.; for(var i=1;i<=12;i++){ var option=document.createElement(“option “); option.text=i; select1.add(option); } body.style.; for(var i=0;i<42;i++) { var span=document.createElement(“span”); span.style.; span.style.; span.style.textAlign=”center”; span. Onmouseover=function(){ this.style.cursor=”hand”; this.tempcolor=this.style.backgroundColor; this.style.backgroundColor=”lightblue”; } span.Onmouseout=function(){ this.style.backgroundColor=this.tempcolor; } span.Onclick=function(){ target.value=select.options[select .selectedIndex].text+”year”+select1.options[select1.selectedIndex].text+”month”+this.innerText+”day”; a.parentNode.removeChild(a); } body .appendChild(span); } select.Onchange=function(){ for(var o in body.all){ body.all[o].innerText=””; if(o.toString()!=”length”) body.all[o].style.backgroundColor=””; } var year1=this.options[this.selectedIndex] .text; var month1=select1.options[select1.selectedIndex].text; var…