Help with maths hugo issues

hi, I need help with how I would archive this … using the build-in Hugo features

I’m trying to get the current age of someone for example
john doe was born 1 January 1998
jane does was born 1 March 1899

how can i get current age using Hugo https://gohugo.io/functions/time/ and math

You can’t. But you could use unix time :wink:

(today - birthday)/ (60s60m24h*365d) is an approximate year diff. You can probably work around the leap-years by taking the year difference divided by 4 rounded down and subtract that from the (today-birthday) calculation.

I realized I had a similar request a while back:

the issue is that im dealling with people born before 1970S

Unix returns the local Time corresponding to the given Unix time, sec seconds and nsec nanoseconds since January 1, 1970, UTC.

Read my second answer. That should solve it.

{{ $start := “2005-01-08” | time }}
{{ $diff := now.Sub $start }}

Here is another sample in pure Go: