The Time registry provides tools to manage and manipulate dates, times, and time-related calculations, making it easy to handle time-based data in your projects.
You can easily import all the functions from the time registry by including the following import statement in your code
import"github.com/go-sprout/sprout/registry/time"
date
The function formats a given date or the current time into a specified format string.
{{ now }} // Output(will be different): "2023-05-07T15:04:05Z"
unixEpoch
The function returns the Unix epoch timestamp for a given date.
Signature
UnixEpoch(date time.Time) string
{{ now | unixEpoch }} // Output(will be different): 1683306245
dateModify
The function adjusts a given date by a specified duration, returning the modified date. If the duration format is incorrect, it returns the original date without any changes, in case of must version, an error is returned.
Signature
DateModify(layout string, date time.Time) (time.Time, error)