開発者向け

Go タイムスタンプ ヘルパー

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)

Go タイムスタンプ ヘルパー

このタイムスタンプツールの詳細

Golang 時間パッケージの例とユーティリティ

目的

このツールを使用して、Unix タイムスタンプとタイム ゾーンの Go タイム パッケージの例を確認します。開発者が本番前に時間データを検証するのに役立ちます。値を入力し、形式またはタイムゾーンを選択して、ログ、API、データベース、自動化、またはドキュメントの正確な結果をコピーします。

メリット

Unix のタイムスタンプとタイム ゾーンの Go タイム パッケージの例を確認するときに、このツールを使用すると作業が速くなります。検証により不正な値が早期に検出され、コピー可能な結果によって転記ミスが防止されます。ブラウザ処理により、繰り返しチェックできるようにデータがデバイス上に保存されます。

ツールの特徴

このツールの便利な機能をご覧ください

基本

使いやすい

誰でも使いやすいシンプルで直感的なインターフェースです。

性能

高速処理

タイムスタンプ操作を素早く効率的に実行します。

品質

正確な結果

精度の高いタイムスタンプ計算と変換を提供します。

MakeTimestampを選ぶ理由

エンタープライズ級の信頼性を備えたタイムスタンプ処理

100%
プライバシー保護
0ms
処理遅延
24/7
常時利用可能
無料
ずっと無料

使い方

このタイムスタンプツールを効果的に使うための簡単な手順

1

データを入力

ツールの入力欄にタイムスタンプまたは日付を入力します。

2

オプションを選択

希望する出力形式や変換オプションを選択します。

3

結果を確認

高い精度で変換結果をすぐに確認できます。

4

コピーして利用

結果をクリップボードにコピーして、アプリやプロジェクトで利用できます。