'setMinutes'에 해당되는 글 1건

  1. 2017.09.08 날짜 초 분 더하기 빼기




 



<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 혜화초보
,