- Día
- Mes
- Hora (en realidad se usa el 15 que significa 3pm)
- Minutos
- Segundos
- Año
- Timezone
Entonces resumiendo, en lugar de utilizar representaciones para hacer el formato, utiliza una fecha:
01/02 03:04:05PM '06 -0700
Ejemplo:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
func main() { | |
t := time.Now() | |
fmt.Println(t.Format("2006-01-02 15:04:05 -0700")) | |
} | |
// 2014-03-03 15:28:00 +0000 UTC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
func main() { | |
value := "Mon, 03/03/14, 03:28PM" | |
layout := "Mon, 01/02/06, 03:04PM" | |
t, _ := time.Parse(layout, value) | |
fmt.Println(t) | |
} | |
// 2014-03-03 15:28:00 +0000 UTC |