var begin = "2017-06-01";
var end = "2017-07-01";
var diffday = getDateDiff(begin, end);
function getDateDiff(date1,date2)
{
var arrDate1 = date1.split("-");
var getDate1 = new Date(parseInt(arrDate1[0]),parseInt(arrDate1[1])-1,parseInt(arrDate1[2]));
var arrDate2 = date2.split("-");
var getDate2 = new Date(parseInt(arrDate2[0]),parseInt(arrDate2[1])-1,parseInt(arrDate2[2]));
var getDiffTime = getDate1.getTime() - getDate2.getTime();
return Math.floor(getDiffTime / (1000 * 60 * 60 * 24));
}
일 차이를 리턴해 준다.
'Tips' 카테고리의 다른 글
현재 위치에서 팝업창 띄우기 (0) | 2017.11.30 |
---|---|
javascript - 팝업창 tab으로 열리는것 방지 (0) | 2017.11.30 |
mysql - timestamp 업데이트 (0) | 2017.11.30 |
javascript - replace를 replaceAll 처럼 사용하기 (0) | 2017.11.30 |
eclipse - 프로젝트 import 방법 (0) | 2017.11.30 |