A
A
Adatan2019-11-15 09:15:17
go
Adatan, 2019-11-15 09:15:17

How to find the difference in two dates and express it in days?

How can I make a similar function in Go?
Python 3.8
example delta_time_days = (datetime.datetime.now() - timestamp).days
delta_time_days = 5
Therefore:
deltaTimeDays := ???

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Gornostaev, 2019-11-15
@Adatan

I don't program in Go, but I googled the answer in a minute

t1 := time.Date(2018, time.Month(1), 1, 0, 0, 0, 0, time.UTC)
t2 := time.Date(2019, time.Month(1), 1, 0, 0, 0, 0, time.UTC)
days := t2.Sub(t1).Hours() / 24
fmt.Println(days)

A
alternativshik, 2019-11-15
@alternativshik

https://lmgtfy.com/?q=golang+datediff+in+days&iie=1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question