타임스탬프 도우미로 이동
Golang 시간 패키지 예제 및 유틸리티
Go Timestamp Examples
Complete guide to working with timestamps in Go. Learn time package, formatting, and best practices.
Get Current Timestamp
Get current Unix timestamp in Go
package main
import (
"fmt"
"time"
)
func main() {
// Get current Unix timestamp in seconds
now := time.Now()
unixSeconds := now.Unix()
fmt.Println("Unix seconds:", unixSeconds) // 1729584000
// Get Unix timestamp in milliseconds
unixMilli := now.UnixMilli()
fmt.Println("Unix milliseconds:", unixMilli) // 1729584000000
// Get Unix timestamp in nanoseconds
unixNano := now.UnixNano()
fmt.Println("Unix nanoseconds:", unixNano)
// Get Unix timestamp in microseconds
unixMicro := now.UnixMicro()
fmt.Println("Unix microseconds:", unixMicro)
}Convert Timestamp to Time
Convert Unix timestamp to time.Time object
package main
import (
"fmt"
"time"
)
func main() {
// From Unix seconds
timestamp := int64(1729584000)
t := time.Unix(timestamp, 0)
fmt.Println(t) // 2024-10-22 01:20:00 +0000 UTC
// From Unix milliseconds
timestampMilli := int64(1729584000000)
t2 := time.UnixMilli(timestampMilli)
fmt.Println(t2)
// From Unix microseconds
timestampMicro := int64(1729584000000000)
t3 := time.UnixMicro(timestampMicro)
fmt.Println(t3)
// Format the time
formatted := t.Format("2006-01-02 15:04:05")
fmt.Println(formatted) // "2024-10-22 01:20:00"
}Parse String to Timestamp
Parse date strings and convert to timestamps
package main
import (
"fmt"
"time"
)
func main() {
// Parse RFC3339 (ISO 8601)
str := "2024-10-22T01:20:00Z"
t, err := time.Parse(time.RFC3339, str)
if err != nil {
panic(err)
}
fmt.Println(t.Unix()) // 1729584000
// Parse custom format
customStr := "2024-10-22 01:20:00"
layout := "2006-01-02 15:04:05"
t2, err := time.Parse(layout, customStr)
if err != nil {
panic(err)
}
fmt.Println(t2.Unix())
// Parse with timezone
loc, _ := time.LoadLocation("America/New_York")
t3, _ := time.ParseInLocation(layout, customStr, loc)
fmt.Println(t3.Unix())
}Quick Reference
Get Current Timestamp
time.Now().Unix()time.Now().UnixMilli()time.Now().UnixNano()Parse Timestamp
time.Unix(sec, 0)time.UnixMilli(ms)time.UnixMicro(micro)Format Time
t.Format("2006-01-02")t.Format(time.RFC3339)t.Format("01/02/2006")Parse String
time.Parse(layout, str)time.ParseInLocation(...)time.ParseDuration(str)타임스탬프 도우미로 이동
이 타임스탬프 도구에 대해 알아보세요
Golang 시간 패키지 예제 및 유틸리티
용도
이 도구를 사용하여 Unix 타임스탬프 및 시간대에 대한 Go 시간 패키지 예제를 검토하세요. 개발자가 생산 전에 시간 데이터를 확인하는 데 도움이 됩니다. 값을 입력하고, 형식이나 시간대를 선택하고, 로그, API, 데이터베이스, 자동화 또는 문서에 대한 정확한 결과를 복사하세요.
장점
Unix 타임스탬프 및 시간대에 대한 Go 시간 패키지 예제를 검토하면 이 도구를 사용하여 더 빠르게 작업할 수 있습니다. 유효성 검사를 통해 잘못된 값을 조기에 발견하고 복사 가능한 결과를 통해 전사 실수를 방지할 수 있습니다. 브라우저 처리는 반복 가능한 검사를 위해 장치에 데이터를 보관합니다.
도구 기능
이 도구의 강점을 확인하세요
사용하기 쉬움
누구나 이해하기 쉬운 직관적인 인터페이스입니다.
빠른 처리
타임스탬프 작업을 빠르고 효율적으로 처리합니다.
정확한 결과
정확한 타임스탬프 계산과 변환을 제공합니다.
타임스탬프 도구를 선택하는 이유
엔터프라이즈급 안정성을 갖춘 전문 타임스탬프 처리
사용 방법
이 타임스탬프 도구를 효과적으로 사용하는 간단한 단계
데이터 입력
도구 입력란에 타임스탬프나 날짜 값을 입력합니다.
옵션 선택
원하는 출력 형식과 추가 옵션을 선택합니다.
결과 확인
높은 정확도로 변환 결과를 즉시 확인합니다.
복사 후 사용
결과를 클립보드에 복사해 앱이나 프로젝트에서 사용합니다.