Skip to content

Instantly share code, notes, and snippets.

@ignaciogutierrez
Created January 31, 2023 21:59
Show Gist options
  • Save ignaciogutierrez/b544a9da2ac131ba3917ae1198c1bfcc to your computer and use it in GitHub Desktop.
Save ignaciogutierrez/b544a9da2ac131ba3917ae1198c1bfcc to your computer and use it in GitHub Desktop.
GoLang Iso8601 Rfc3339 MST Time
// Crear un string que represente una fecha, usando la constante time.RFC3339 o ISO8601
// https://go.dev/play/p/NHrC8lCeiuV
//
package main
import (
"fmt"
"time"
)
func main() {
// Hora actual usando la zona local de tu equipo
now := time.Now()
// EST = Hora del Este (NY,Boston)
// CST = Hora del Centro (Chicago, DF)
// MST = Hora de Montana (Denver, Phoenix, Hermosillo)
// PST = Hora de Pacifico (LA, Tijuana)
// Definir una locacion
//loc, _ := time.LoadLocation("America/Monterrey")
//loc, _ := time.LoadLocation("America/Phoenix")
loc, _ := time.LoadLocation("MST")
// created, es un string con la hora actual en MST = Phoenix = SLRC
// Usar la constante time.RFC3339
created := time.Now().In(loc).Format(time.RFC3339)
// Mostrar los valores
fmt.Printf("%s\n", now.String())
fmt.Printf("\nFecha en Formato iso8601\n%s\n", created)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment