T
T
TemaKam2021-09-29 12:18:56
go
TemaKam, 2021-09-29 12:18:56

How to convert string type to time?

there is a string with timestamp in it
how can i just convert this string type to time type? so that it remains in the timestamp

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2021-09-29
@udjin123

package main

import (
    "fmt"
    "time"
    "strconv"
)

func main() {
    i, err := strconv.ParseInt("1632896473", 10, 64)
    if err != nil {
        panic(err)
    }
    tm := time.Unix(i, 0)
    fmt.Println(tm.Unix())
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question