Add minutes to .Date

Hi all!

Is it possible to add n minutes to .Date—for a calendar function.

This is what I tried to do:

{{ .Date.Add(time.Hour 2) }}

Thank you

Untested, but perhaps…

{{.Date.AddDate 0 0 2 }}

Correction, I believe that AddDate is Y M H, so you could try a fraction perhaps? Not at my computer right now but will test shortly…

Thank you very much.

Yes, it is Y M D.

A fraction does not seem possible here.

Still no success here. I guess, I tried every combination possible :slightly_smiling:

Adding hours or minutes seems difficult—unlike Y, M or D.

Has anyone an idea?

Gosh! The following code ist most ugly and not a definite solution:

{{ add .Date.Hour 1 }}:{{ add .Date.Minute 30 }}

Only for events starting before 22:30, of course.

Just no success with .Date.Add and time.duration.

So are you saying this does or does not get you what you want in your final output?

Well, what I really need is this:

add “n” minutes to any .Date, respecting change of date including leapyear and everything.

A post was split to a new topic: Add minutes to date