가이드
JavaScript에서 타임스탬프가 이상하게 보이는 이유
초/밀리초 혼동과 시간대 설정 문제로 생기는 JS 날짜 오류를 정리합니다.
JavaScript Date가 틀린 것이 아니라 입력 단위나 시간대 해석이 잘못된 경우가 대부분입니다.
JavaScript Date expects milliseconds
new Date(value) expects milliseconds in most timestamp workflows.
Passing seconds directly creates incorrect output.
Local time vs UTC confusion
Some methods show local timezone by default.
Use UTC-aware formatting when you need environment-independent results.
Debug checklist
Follow this order to isolate the issue quickly.
- Confirm unit length.
- Convert to UTC and local for comparison.
- Check source API timezone assumptions.
Avoid hidden string parsing issues
Different date string formats can parse inconsistently.
Prefer numeric timestamps or ISO-8601 strings for predictable behavior.
Typical problems
- Date near 1970 appears unexpectedly.
- Correct day but wrong hour.
- Different time in frontend vs backend.
- Broken date formatting in UI.
Debug unit first, timezone second
Most JavaScript timestamp bugs are solved by checking units and then checking timezone conversion.