Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: retrieving datetime from mysql in time.time in golang

ocuparedu:

i have stored on my database (mySQL) this datatime field, last_activity: 2017-06-12 11:07:09

im using the param parseTime=True on my OpenDB

the problem is that the output is: last activity: {63632862429 0 } instead of 2017-06-12 11:07:09

what am i doing wrong?

thanks


type DateType time.Time

type User struct {
LastActivity DateType
}


func (stUser *User) GetUserDataByLogin(login string) {

db := OpenDB()

defer db.Close()

// Test the connection to the database
err := db.Ping()
checkErr(err)

err = db.QueryRow("SELECT last_activity FROM users WHERE login = ?", login).Scan(&stUser.LastActivity)

if err != nil {
if err == sql.ErrNoRows {
// there were no rows, but otherwise no error occurred
} else {
log.Fatal(err)
}
}

fmt.Println("last activity:", stUser.LastActivity)

}



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered
HERE


This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: retrieving datetime from mysql in time.time in golang

×

Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription

×