std.integer2time

TIMEstd.integer2timeINTEGERtime

Available in all subroutines.

Converts an integer, representing seconds since the Unix Epoch, to a time variable.

If the time argument is invalid then this returns a time value that stringifies to datetime out of bounds.

To convert a string, use std.time instead.

Example

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

Try it out

std.integer2time is used in the following solution recipes, which show real world use cases. Click RUN to provision a Fastly service, execute the code on Fastly, and see how the function behaves.

Relative date insertion using ESI

Generate relative time datelines like "3 minutes ago" at the Edge instead of in JavaScript or at origin. Better caching, faster rendering, fewer reflows.

JSON web tokens

Decode the popular JWT format to verify user session tokens before forwarding trusted authentication data to your origin.

Time formatting

Format dates and times in a variety of ways.

User contributed notes

We welcome comments that add use cases, ideas, tips, and caveats. All comments will be moderated before publication. To post support questions, visit our support center and we'll find you the help you need.