---
title: std.time
summary: null
url: >-
  https://www.fastly.com/documentation/reference/vcl/functions/date-and-time/std-time
---

```
TIME std.time(STRING s, TIME fallback)
```

**Available in:** all subroutines

Converts a string to a time variable.

The following string formats are supported:

- `Mon, 02 Jan 2006 22:04:05 GMT`, [RFC 822](https://tools.ietf.org/html/rfc822) 
  and [RFC 1123](https://tools.ietf.org/html/rfc1123)
- `Monday, 02-Jan-06 22:04:05 GMT`, [RFC 850](https://tools.ietf.org/html/rfc850)
- `Mon Jan 2 22:04:05 2006`, 
  ANSI-C [asctime()](https://www.unix.com/man-page/FreeBSD/3/asctime/)
- `2006-01-02 22:04:05`, an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) 
  subset
- `1136239445.00`, seconds since the 
  [Unix Epoch](https://en.wikipedia.org/wiki/Unix_time)
- `1136239445`, seconds since the 
  [Unix Epoch](https://en.wikipedia.org/wiki/Unix_time)

The only time zone supported is `GMT`.

If the string does not match one of those formats, then the fallback variable 
is returned instead. We recommend using a fallback that's meaningful for your 
particular Fastly service.

## Example

```vcl
declare local var.time1 TIME;
set var.time1 = std.time("Mon, 02 Jan 2006 22:04:05 GMT", now);
# var.time1 is now "Mon, 02 Jan 2006 22:04:05 GMT"

declare local var.time2 TIME;
set var.time2 = std.time("1136239445", std.integer2time(0));
# var.time2 is now "Mon, 02 Jan 2006 22:04:05 GMT"

declare local var.time3 TIME;
set var.time3 = std.time("Not a date", std.integer2time(-1));
# var.time3 is now "datetime out of bounds"
```
