Render dates and times with offsets
Hoverfly Cloud has powerful templating features to render the date and time with offsets as required based on the underlying Go programming language.
The Go language uses a fixed reference time — Mon Jan 2 15:04:05 MST 2006 — to define date/time layouts. Each element of that date maps to a component (e.g., 2006
= year, 01
= month, 02
= day, 15
= 24h hour, 03
= 12h hour, 04
= minutes, 05
= seconds, MST
= time zone). This format, inherited from Plan 9, was chosen as a mnemonic since the digits 1–7 appear in order across the reference. https://golang.org/pkg/time/#Parse
NOTE! It is important to use the fixed referenced date and time when applying a format to a date. Do not use todays date or any other date.
Description
Example
Result
The current date time with offset, in the given format.
For example:
The current date time plus 1 day in unix timestamp
The current date time in ISO 8601 format
The current date time minus 1 day in custom format
{{ now '1d' 'unix' }}
{{ now '' '' }}
{{ now '-1d' '2006-Jan-02' }}
1136300645
2006-01-02T15:04:05Z
2006-Jan-01
Examples
ANSIC
{{now '' 'Mon Jan _2 15:04:05 2006'}}
Wed Sep 17 14:31:18 2025
UnixDate
{{now '' 'Mon Jan _2 15:04:05 MST 2006'}}
Wed Sep 17 14:31:18 UTC 2025
RubyDate
{{now '' 'Mon Jan 02 15:04:05 -0700 2006'}}
Wed Sep 17 14:31:18 +0000 2025
RFC822
{{now '' '02 Jan 06 15:04 MST'}}
17 Sep 25 14:31 UTC
RFC822Z
{{now '' '02 Jan 06 15:04 -0700'}}
17 Sep 25 14:31 +0000
RFC850
{{now '' 'Monday, 02-Jan-06 15:04:05 MST'}}
Wednesday, 17-Sep-25 14:31:18 UTC
RFC1123
{{now '' 'Mon, 02 Jan 2006 15:04:05 MST'}}
Wed, 17 Sep 2025 14:31:18 UTC
RFC1123Z
{{now '' 'Mon, 02 Jan 2006 15:04:05 -0700'}}
Wed, 17 Sep 2025 14:31:18 +0000
RFC3339
{{now '' '2006-01-02T15:04:05Z07:00'}}
2025-09-17T14:31:18Z
RFC3339Nano
{{now '' '2006-01-02T15:04:05.999999999Z07:00'}}
2025-09-17T14:31:18.260445005Z
Kitchen
{{now '' '3:04PM'}}
2:31PM
Using offsets
When using template helper method now
, time offset must be formatted using the following syntax.
Shorthand
Type
ns
Nanosecond
us/µs
Microsecond
ms
Millisecond
s
Second
m
Minute
h
Hour
d
Day
y
Year
Prefix an offset with -
to subtract the duration from the current date time.
Example time offset
5m
5 minutes
1h30m
1 hour 5 minutes
1y10d
1 year 10 days
Examples
RFC1123Z +1 day = {{now '1d' 'Mon, 02 Jan 2006 15:04:05 -0700'}} RFC1123Z -1 day = {{now '-1d' 'Mon, 02 Jan 2006 15:04:05 -0700'}} RFC1123Z +5mins = {{now '5m' 'Mon, 02 Jan 2006 15:04:05 -0700'}} RFC1123Z -5mins = {{now '-5m' 'Mon, 02 Jan 2006 15:04:05 -0700'}} RFC1123Z +1h30min = {{now '1h30m' 'Mon, 02 Jan 2006 15:04:05 -0700'}} RFC1123Z -1h30min = {{now '-1h30m' 'Mon, 02 Jan 2006 15:04:05 -0700'}} RFC1123Z +1y10d = {{now '1y10d' 'Mon, 02 Jan 2006 15:04:05 -0700'}} RFC1123Z -1y10d = {{now '-1y10d' 'Mon, 02 Jan 2006 15:04:05 -0700'}}
Last updated