How does Golang automatically convert the received timestamp to time? Gin used

The frames used by

are gin and gorm . Now the front-end request interface is uploaded and is a timestamp. What should be done to automatically convert the received timestamp to time.Time . What comes from the front end is an json data. Parsing is a problem when using ShouldBindJSON .

May.22,2022

customize a type when using TimeStamp to implement the corresponding method: the code is as follows:

  

I am using gin @ v1.4 version, and json supports direct conversion to time.Time type.
however, custom data formats are not supported. That is, only RFC3339 format (that is, "2006-01-02T15:04:05Z07:00" ) is supported.

Menu