In a DB I have a field of type int64
in which I store unix timestamp. Then I want to present it to the user as a normal datetime
, as a string. However, it'll fail. Here's a simple example.
package main
import (
"fmt"
"strconv"
)
func main() {
var a int64
a = 1658545089
tm, err := strconv.ParseInt(string(a), 10, 64)
if err != nil {
panic(err)
}
fmt.Println(tm)
}
===>
panic: strconv.ParseInt: parsing "�": invalid syntax
What's going on here?