js 현재 날짜 / 년도 / 월 가 져 오기

5337 단어 js
function getNowFormatDate() {      var   date =  new   Date();      var   seperator1 =  "-" ;      var   seperator2 =  ":" ;      var   month = date.getMonth() + 1;      var   strDate = date.getDate();      if   (month >= 1 && month <= 9) {          month =  "0"   + month;      }      if   (strDate >= 0 && strDate <= 9) {          strDate =  "0"   + strDate;      }      var   currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate              " "   + date.getHours() + seperator2 + date.getMinutes()              + seperator2 + date.getSeconds();      return   currentdate; } ------------------------------------------------------------------

js , :201208
      
 //
 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());

,year.toString()+month.toString() year+month。 10, , , 201210, 2022, .toString()


 

var myDate = new Date();
myDate.getYear(); // (2 )
myDate.getFullYear(); // (4 ,1970-????)
myDate.getMonth(); // (0-11,0 1 )
myDate.getDate(); // (1-31)
myDate.getDay(); // X(0-6,0 )
myDate.getTime(); // ( 1970.1.1 )
myDate.getHours(); // (0-23)
myDate.getMinutes(); // (0-59)
myDate.getSeconds(); // (0-59)
myDate.getMilliseconds(); // (0-999)
myDate.toLocaleDateString(); //
var mytime=myDate.toLocaleTimeString(); //
myDate.toLocaleString( ); //

 

 

<br> function monthnow(){<br>  var now   = new Date();<br>  var monthn = now.getMonth();<br>  var yearn  = now.getYear();<br>  window.location.href="winnNamelist.jsp?getMonth="+monthn+"&getYear="+yearn;<br> }<br>


좋은 웹페이지 즐겨찾기