파라미터가 p_yyyy , p_mm , p_dd   이다.

11 개월을 빼라!!



var p_yyyy_i = parseInt( p_yyyy );

var p_mm_i = parseInt( p_mm );

var p_dd_i = parseInt( p_dd );


var dat1 = new Date( p_yyyy_i,   p_mm_i  - 1 , p_dd_i  );

//var dat1 = new Date(  2017  , 12  ,   3 );

dat1.setMonth( dat1.getMonth() - 11 ); 

console.log("* 3년 빼기 : " + (dat1.getFullYear() ) + "-" + (dat1.getMonth() +1 ) + "-" + dat1.getDate() + "  ");

var rst1 = dat1.getFullYear();

var rst2 = pad( dat1.getMonth() +1  , 2 )  ;

return rst1 + rst2;





 


'[.js] 날짜' 카테고리의 다른 글

현재날짜 YYYYMMDDHHMMSS  (0) 2018.10.05
날짜 초 분 더하기 빼기  (0) 2017.09.08
현재 날짜 구하기  (0) 2017.09.06
이달의 마지막날짜 구하기  (0) 2017.09.06
Posted by 혜화초보
,





 




/*

 *   YYYYMMDDHHMMSS

 *   형식으로 날짜를 리턴한다.

 */

function getDate(){

     var currentdate = new Date(); 


 var rst = pad(  currentdate.getFullYear() , 2 ) 

+  pad(  (currentdate.getMonth()+1)  , 2 ) 

     + pad( currentdate.getDate() , 2 ) 

     + pad(  currentdate.getHours() , 2 )   

     + pad(  currentdate.getMinutes() , 2 ) ; 

 return rst;

}


function pad(number, length) {

    var str = '' + number;

    while (str.length < length) {

        str = '0' + str;

    }

    return str;

}    












'[.js] 날짜' 카테고리의 다른 글

날짜 빼기 , 11개월전 날짜 구하기  (0) 2018.11.21
날짜 초 분 더하기 빼기  (0) 2017.09.08
현재 날짜 구하기  (0) 2017.09.06
이달의 마지막날짜 구하기  (0) 2017.09.06
Posted by 혜화초보
,




 



<html>

<head>

</head>


<script  language="javascript"  >


function init(){


  var today = new Date();

  today.setDate(today.getDate() + 30); //Date after 30 days

  var year = today.getFullYear();

  var month = today.getMonth() + 1;

  var day = today.getDate();

  var min = '';

  var sec = '';

  console.log( year + '-' + month + '-' + day );


  today = new Date();

  today.setDate(today.getDate() - 30); // Date before 30 days

  year = today.getFullYear();

  month = today.getMonth() + 1;

  day = today.getDate();  

  console.log( year + '-' + month + '-' + day );

  

  today = new Date();  

  today.setMinutes(today.getMinutes() + 30); //After 30 minutes

  year = today.getFullYear();

  month = today.getMonth() + 1;

  day = today.getDate();    

  min = today.getMinutes();  

  console.log( year + '-' + month + '-' + day + '-' + min );  


  today = new Date();

  year = today.getFullYear();

  month = today.getMonth() + 1;

  day = today.getDate();   

  min = today.getMinutes();     

  sec = today.getSeconds();

  console.log( year + '-' + month + '-' + day + '-' + min + '-' + sec );

  

  today = new Date();

  year = today.getFullYear();

  month = today.getMonth() + 1;  

  min = today.getMinutes();      

  sec = today.setSeconds( today.getSeconds() + 500 );   //After 500 seconds

  sec = today.getSeconds();

  console.log( year + '-' + month + '-' + day + '-' + min + '-' + sec );


}


</script>

    <body  onload="init();" >

        <div id="groundDiv"  style="position:relative;"></div>

        <div id='a1'  style="position:absolute;" ></div>

        <input type='text'  size='20'       >

    </body>

</html>

 







'[.js] 날짜' 카테고리의 다른 글

날짜 빼기 , 11개월전 날짜 구하기  (0) 2018.11.21
현재날짜 YYYYMMDDHHMMSS  (0) 2018.10.05
현재 날짜 구하기  (0) 2017.09.06
이달의 마지막날짜 구하기  (0) 2017.09.06
Posted by 혜화초보
,



function exe(){

   var dt = new Date();

  

   var month = dt.getMonth()+1;

   var day = dt.getDate();

   var year = dt.getFullYear();

   var result  = month + '-' + day + '-' + year;

   

   console.log(  '' + result   );  

 }


'[.js] 날짜' 카테고리의 다른 글

날짜 빼기 , 11개월전 날짜 구하기  (0) 2018.11.21
현재날짜 YYYYMMDDHHMMSS  (0) 2018.10.05
날짜 초 분 더하기 빼기  (0) 2017.09.08
이달의 마지막날짜 구하기  (0) 2017.09.06
Posted by 혜화초보
,




 




<html>

<head>

</head>

<script  language="javascript"  >

 

// 2016 , 2  값을 변수 처리 하면 됩니다.

// 2016년 2월의 마지막 일자를 리턴.

 function exe(){

     var lastDay = new Date( 2016 , 2 , 0);

     console.log(' lastDay: '+ lastDay );

 }


</script>

    <body  >

        <div  style="  height:200px ; padding-top:200px ; padding-left:200px "  >

          <a href="javascript:exe();"  >  click  </a>        

        </div>

    </body>

</html>







'[.js] 날짜' 카테고리의 다른 글

날짜 빼기 , 11개월전 날짜 구하기  (0) 2018.11.21
현재날짜 YYYYMMDDHHMMSS  (0) 2018.10.05
날짜 초 분 더하기 빼기  (0) 2017.09.08
현재 날짜 구하기  (0) 2017.09.06
Posted by 혜화초보
,