> For the complete documentation index, see [llms.txt](https://docs.cloud.hoverfly.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cloud.hoverfly.io/create-simulations/using-templating-in-simulations/render-dates-and-times-with-offsets.md).

# 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.

<table data-header-hidden><thead><tr><th></th><th width="285"></th><th></th></tr></thead><tbody><tr><td>Description</td><td>Example</td><td>Result</td></tr><tr><td><p>The current date time with offset, in the given format.</p><p>For example:</p><ul><li>The current date time plus 1 day in unix timestamp</li><li>The current date time in ISO 8601 format</li><li>The current date time minus 1 day in custom format</li></ul></td><td><ul><li><code>{{ now '1d' 'unix' }}</code></li><li><code>{{ now '' '' }}</code></li><li><code>{{ now '-1d' '2006-Jan-02' }}</code></li></ul></td><td><ul><li>1136300645</li><li>2006-01-02T15:04:05Z</li><li>2006-Jan-01</li></ul></td></tr></tbody></table>

## Examples

<table><thead><tr><th width="135">Format</th><th width="321">Handlebars syntax</th><th>Result</th></tr></thead><tbody><tr><td>ANSIC</td><td><code>{{now '' 'Mon Jan _2 15:04:05 2006'}}</code></td><td>Wed Sep 17 14:31:18 2025</td></tr><tr><td>UnixDate</td><td><code>{{now '' 'Mon Jan _2 15:04:05 MST 2006'}}</code></td><td>Wed Sep 17 14:31:18 UTC 2025</td></tr><tr><td>RubyDate</td><td><code>{{now '' 'Mon Jan 02 15:04:05 -0700 2006'}}</code></td><td>Wed Sep 17 14:31:18 +0000 2025</td></tr><tr><td>RFC822</td><td><code>{{now '' '02 Jan 06 15:04 MST'}}</code></td><td>17 Sep 25 14:31 UTC</td></tr><tr><td>RFC822Z</td><td><code>{{now '' '02 Jan 06 15:04 -0700'}}</code></td><td>17 Sep 25 14:31 +0000</td></tr><tr><td>RFC850</td><td><code>{{now '' 'Monday, 02-Jan-06 15:04:05 MST'}}</code></td><td>Wednesday, 17-Sep-25 14:31:18 UTC</td></tr><tr><td>RFC1123</td><td><code>{{now '' 'Mon, 02 Jan 2006 15:04:05 MST'}}</code></td><td>Wed, 17 Sep 2025 14:31:18 UTC</td></tr><tr><td>RFC1123Z</td><td><code>{{now '' 'Mon, 02 Jan 2006 15:04:05 -0700'}}</code></td><td>Wed, 17 Sep 2025 14:31:18 +0000</td></tr><tr><td>RFC3339</td><td><code>{{now '' '2006-01-02T15:04:05Z07:00'}}</code></td><td>2025-09-17T14:31:18Z</td></tr><tr><td>RFC3339Nano</td><td><code>{{now '' '2006-01-02T15:04:05.999999999Z07:00'}}</code></td><td>2025-09-17T14:31:18.260445005Z</td></tr><tr><td>Kitchen</td><td><code>{{now '' '3:04PM'}}</code></td><td>2:31PM</td></tr></tbody></table>

## 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'}}
