js 복귀 시간 스탬프 차이

950 단어 js
<span style="white-space:pre">	</span>function timeDefference(startTime, endTime) {
		var t1 = new Date(startTime);
		var t2 = new Date(endTime);
		if (t1.getFullYear() - t2.getFullYear() > 0) {
			var result = t1.getFullYear() - t2.getFullYear();
			alert(result+"year")
			return;
		}
		if (t1.getMonth() - t2.getMonth() > 0) {
			var result = t1.getMonth() - t2.getMonth();
			alert(result+"mounth")
			return;
		}
		if (t1.getDate() - t2.getDate() > 0) {
			var result = t1.getDate() - t2.getDate();
			alert(result+"date")
			return;
		}
		if (t1.getHours() - t2.getHours() > 0) {
			var result = t1.getHours() - t2.getHours();
			alert(result+"hour")
			return;
		}
		if (t1.getMinutes() - t2.getMinutes() > 0) {
			var result = t1.getMinutes() - t2.getMinutes();
			alert(result+"minutes")
			return;
		}
		return "  "
		
	}

좋은 웹페이지 즐겨찾기