Apoya a Time.now: Únete a nuestro Plan Premium ¡para una experiencia sin anuncios! Apóyanos: ¡Hazte Premium sin anuncios!
Backend Guía

Consuming Time JSON in Go

Go is strict about types. Our API returns a consistent schema, making it easy to unmarshal into Go structs for robust system tools and backend services.

GO
package main

import (
    "encoding/json"
    "fmt"
    "net/http"
)

type TimeResponse struct {
    Datetime string `json:"datetime"`
    Timezone string `json:"timezone"`
    UnixTime int64  `json:"unixtime"`
}

func main() {
    resp, err := http.Get("https://time.now/developer/api/timezone/Europe/Berlin")
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

    var record TimeResponse
    if err := json.NewDecoder(resp.Body).Decode(&record); err != nil {
        panic(err)
    }

    fmt.Printf("Time in %s is %s\n", record.Timezone, record.Datetime)
}

¿Por qué usar Time.Now para Backend?

  • Strict JSON Schema
  • Fast execution for system tools
  • Easy struct mapping
Referencia de la API Ver todas las guías