JQuery 날짜변경 이벤트
//시작일자를 변경 시 종료일자를 시작일자로 셋팅
$(document).on('change', '#fromDate', function() {
$('#toDate').val($('#fromDate').val());
});
//오늘날짜 구하기
function getToday(){
var now = new Date();
var year = now.getFullYear();
var month = now.getMonth() + 1; //1월이 0으로 되기때문에 +1을 함.
var date = now.getDate();
month = month >=10 ? month : "0" + month;
date = date >= 10 ? date : "0" + date;
//console.log(""+year + month + date);
return today = ""+year + month + date;
}
//날짜 속성
$(document).ready(function(){
var now = new Date(); //전체
var year=now.getFullYear();//연도
var month=now.getMonth()+1;//월
var date=now.getDate();//일
var day=now.getDay();//요일
var hr=now.getHours();//시간
var min=now.getMinutes();//분
var sec=now.getSeconds();//초
});
//날짜포멧 별 출력
var date = new Date();
console.log(date.toLocaleString()); // 2021. 7 24 오후 13:00:00
console.log(date.toLocaleDateString()); // 2021. 7. 24
console.log(date.toLocaleTimeString()); // 오후 13:00:00
//detepicker 달력
<!doctype html>
<html lang="kr">
<head>
<meta charset="utf-8">
<title>jQuery UI(Datepicker)달력 </title>
<link rel="stylesheet" href="/libs/jqueryui/1.10.4/css/jquery-ui.min.css">
<script src="/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
<link rel="stylesheet" href="jqueryui/style.css">
<script>
$(function() {
$( "#datepicker" ).datepicker();
});
</script>
</head>
<body>
달력:<div id="datepicker"></div>
</body>
</html>
<<<결과>>>