The time type of go language is stored in timestamp

1. mysql database field type timestamp

  `created_at` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP

2. Model type

type Books struct {

	CreatedAt  time.Time
	UpdatedAt  time.Time
}

3. Type assignment

time.Now().UTC().Truncate(time.Microsecond)

Guess you like

Origin blog.csdn.net/qq960685827/article/details/123440943