Skip to content

time: since or time.Now().Sub(t) returns wrong when t is start date of the calender #61396

@ErfanMomeniii

Description

@ErfanMomeniii

What version of Go are you using (go version)?

$ go version
1.20.3

What did you expect to see?

I wanted to calculate the number of seconds that have passed since the start of the calendar.

fmt.Println(time.Now().UTC().Sub(time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)))

it returned the wrong answer.

2562047h47m16.854775807s

from the number of hours, we can calculate 292 years but we are in 2023 now.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions