Skip to content

Instantly share code, notes, and snippets.

@franklinsales
Created April 14, 2017 19:11
Show Gist options
  • Save franklinsales/b450047a6086b029e1fadf5eeeeec840 to your computer and use it in GitHub Desktop.
Save franklinsales/b450047a6086b029e1fadf5eeeeec840 to your computer and use it in GitHub Desktop.
Just a raw gist where I handle in go a datetime value in mysql format
package main
import (
"fmt"
"time"
)
func main() {
datetimeFormat := "2006-01-02 15:04:05"
timeNow := time.Now().Format(datetimeFormat) // 2009-11-10 23:00:00 (value of Go Playground)
fmt.Println(timeNow)
fmt.Printf("%T\n", timeNow) //String
fmt.Println("----------------\n")
vUint8Array := []uint8(timeNow)
fmt.Println(vUint8Array)
fmt.Printf("%T\n", vUint8Array) //uint8 type value of go-sql-driver/mysql
fmt.Println("----------------\n")
fmt.Println(string(vUint8Array)) //String
fmt.Println("----------------\n")
fmt.Println(time.Parse(datetimeFormat, timeNow)) //2009-11-10 23:00:00 +0000 UTC <nil>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment