시간비교
-
[javascript] date time difference, 날짜 시간 비교 함수Programing/javascript 2020. 9. 9. 09:42
- 시간 절대값 비교(날짜 무시) const HOUR_TO_SEC = 3600; const MINUTE_TO_SEC = 60; const timeDiff = (_date1: any, _date2: any) => { const diff = moment.utc(moment(_date1, "YYYY-MM-DD HH:mm:ss").diff(moment(_date2, "YYYY-MM-DD HH:mm:ss"))).format("HH:mm:ss"); const hour_to_second = parseInt(diff.substring(0, 2)) * HOUR_TO_SEC; const minute_to_second = parseInt(diff.substring(3, 5)) * MINUTE_TO_SEC; const sec..