17 lines
411 B
HTML
17 lines
411 B
HTML
{{ $birth := "2000-10-28" | time }}
|
|
{{ $today := now }}
|
|
{{ $age := sub $today.Year $birth.Year }}
|
|
{{ $monthDiff := sub $today.Month $birth.Month }}
|
|
{{ $dayDiff := sub $today.Day $birth.Day }}
|
|
|
|
{{ if (gt $monthDiff 0) }}
|
|
{{ $age }}
|
|
{{ else if (lt $monthDiff 0) }}
|
|
{{ sub $age 1 }}
|
|
{{ else }}
|
|
{{ if (ge $dayDiff 0) }}
|
|
{{ $age }}
|
|
{{ else }}
|
|
{{ sub $age 1 }}
|
|
{{ end }}
|
|
{{ end }}
|