현재 Unix 타임스탬프의 의미
현재 Unix 타임스탬프는 1970년 1월 1일 00:00:00 UTC 이후 경과한 정수 초의 수입니다. 실시간 에포크 시계는 1초마다 1씩 증가합니다. 시계가 밀리초를 표시하면 1초에 여러 번 증가하며 보통 13자리 값입니다.
왜 UTC가 기준인가
Unix 시간은 UTC를 기준으로 하여 서로 다른 시간대의 컴퓨터가 같은 순간에 대해 하나의 숫자 값으로 합의할 수 있습니다. 로컬 시간은 표시 계층일 뿐입니다. 두 사용자가 같은 순간에 페이지를 열면, 한 명은 아침이고 다른 한 명은 저녁이어도 같은 현재 Unix 타임스탬프를 공유합니다.
현재 Unix 타임스탬프를 얻는 방법
모든 주요 언어에는 현재 Unix 시간을 얻는 짧은 방법이 있습니다.
- JavaScript 밀리초: Date.now()
- JavaScript 초: Math.floor(Date.now() / 1000)
- Linux 초: date +%s
- Python 초: int(time.time())
- PHP 초: time()
- Go 초: time.Now().Unix()
- PostgreSQL 초: EXTRACT(EPOCH FROM now())
현재 타임스탬프 vs 포맷된 시간
타임스탬프는 정렬, 비교, 저장, API 페이로드에 유용합니다. 포맷된 날짜는 사람에게 유용합니다. 대부분의 애플리케이션은 타임스탬프나 UTC 날짜·시간을 저장하고 사용자에게 표시할 때만 포맷합니다.
- 데이터베이스와 로그에는 UTC나 Unix 타임스탬프를 저장하세요
- 사용자의 시간대로 로컬 시간을 표시하세요
- 사람이 API 페이로드를 검사해야 할 때는 ISO 8601을 사용하세요
- 시스템이 간결한 숫자 값을 필요로 할 때는 Unix 초나 밀리초를 사용하세요
FAQ
- Does the current Unix timestamp depend on my timezone?
- No. The timestamp is based on UTC and is the same worldwide for the same instant.
- Why is my current timestamp 13 digits?
- A 13-digit current timestamp is usually milliseconds. Divide by 1000 to get Unix seconds.
- Where can I see a live Unix epoch clock?
- The converter homepage shows a live epoch clock and lets you convert the value to UTC or local time.
- Is the current Unix timestamp the same in every programming language?
- Yes for the instant, but not always for the unit. JavaScript's Date.now() and Java's System.currentTimeMillis() return milliseconds, while Python time.time(), PHP time(), Go Unix(), and Linux date +%s return seconds. Confirm the unit before comparing or storing values.