I am creating a date using Go via time.Now()
and it store it in the mongoDB with no issue. The date looks like 2023-02-28T20:10:46.140+00:00
.
However when I try to retrieve it I get an error that reads:
{{"code":2, "message":"parsing time \"2023-02-28 20:10:46.14 +0000 UTC\" as \"2006-01-02T15:04:05Z07:00\": cannot parse \" 20:10:46.14 +0000 UTC\" as \"T\"", "details":[]}
It is coming from this piece of code.
createdAt, err := time.Parse(time.RFC3339, blog.CreatedAt.String())
if err != nil {
return nil, err
}
updatedAt, err := time.Parse(time.RFC3339, blog.UpdatedAt.String())
if err != nil {
return nil, err
}
tempBlog := &api.Blog{
Id: blog.ID,
CreatedAt: timestamppb.New(createdAt),
UpdatedAt: timestamppb.New(updatedAt),
I found some useful documentation here and here and added the times parsed into Mongo manually, but I still run into this issue.
I have tried all of the time formats but it just results in a different error that is not able to parse.
Advice?