- 정보공유
[기타] 자바스크립트 날짜 계산 사파리 safari 브라우저도 가능
자바스크립트 날짜 계산 사파리 safari 브라우저도 가능
function wz_dateDiff(_date1, _date2) {
var diffDate_1 = _date1.replace(/-/gi,"/");
diffDate_1 = new Date(diffDate_1);
var diffDate_2 = _date2.replace(/-/gi,"/");
diffDate_2 = new Date(diffDate_2);
diffDate_1 =new Date(diffDate_1.getFullYear(), diffDate_1.getMonth()+1, diffDate_1.getDate());
diffDate_2 =new Date(diffDate_2.getFullYear(), diffDate_2.getMonth()+1, diffDate_2.getDate());
var diff = Math.abs(diffDate_2.getTime() - diffDate_1.getTime());
diff = Math.ceil(diff / (1000 * 3600 * 24));
return diff;
}