I have a problem retrieving data in the database. why insert with different output results at created_at
and updated_at
?
I am still a beginner for Go programming
Struct:
type Builder struct {
Id int `json:"id"`
Name string `json:"name"`
Created_at time.Time `json:"created_at"`
Updated_at time.Time `json:"updated_at"`
}
DB :
CREATE TABLE test_types (
id bigint NOT NULL AUTO_INCREMENT,
name varchar(100) NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE now(),
PRIMARY KEY (id)
);
INSERT INTO test_types (id, name, created_at) VALUES (1, 'Welcome Screen', '2019-03-23 00:00:00');
with the following results:
insert : 2019-03-23 00:00:00
output : “0001-01-01T00:00:00Z”
why is it different between inserts and outputs, is it parsing my data incorrectly?
Try to insert date like this
"2022-01-09T00:00:00Z"
or
"1996-01-01T00:00:00+00:00"