std.time

TIMEstd.timeSTRINGsTIMEfallback

Available inall subroutines.

Converts a string to a time variable.

The following string formats are supported:

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

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"

Try it out

std.time is used in the following code examples. Examples apply VCL to real-world use cases and can be deployed as they are, or adapted for your own service. See the full list of code examples for more inspiration.

Click RUN on a sample below to provision a Fastly service, execute the code on Fastly, and see how the function behaves.

Format time expressions

Format dates and times in a variety of ways.