currentDate = new Date();
currentDate.getDate();
// 1491553506653를 반환
나열된 시간은 millisecond 즉 1/1000초를 나타냄
1970년 1월 1일 자정을 기준으로 함
function getDateDiff(date1,date2) {
let arrDate1 = date1.split("-");
let getDate1 = new Date(parseInt(arrDate1[0]),parseInt(arrDate1[1])-1,parseInt(arrDate1[2]));
let arrDate2 = date2.split("-");
let getDate2 = new Date(parseInt(arrDate2[0]),parseInt(arrDate2[1])-1,parseInt(arrDate2[2]));
let getDiffTime = getDate1.getTime() - getDate2.getTime();
let eventDays = Math.floor(getDiffTime / (1000 * 60 * 60 * 24));
return eventDays;
}
function getDay() {
let week = ['일', '월', '화', '수', '목', '금', '토'];
let dayOfWeek = week[new Date('2016-07-28').getDay()];
return dayOfWeek;
}
function getDatesStartToLast(startDate, lastDate) {
var regex = RegExp(/^\d{4}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$/);
if(!(regex.test(startDate) && regex.test(lastDate))) return "Not Date Format";
var result = [];
var curDate = new Date(startDate);
while(curDate <= new Date(lastDate)) {
result.push(curDate.toISOString().split("T")[0]);
curDate.setDate(curDate.getDate() + 1);
}
return result;
}
날짜사이 일 수
특정날짜가 무슨 요일
날짜 사이의 모든 날짜
datepicker 사용법
datepicker 꾸미기