localtime

datetime

Converts a timestamp to local timezone

Syntax

localtime(timestamp)

Parameters

timestamp (timestamp)

The timestamp to convert to local time

Returns

timestamp

The timestamp adjusted to local timezone

Examples

Convert UTC to local time
Input:
localtime("2024-01-15 14:30:00")
Output:
"2024-01-15 09:30:00"
Adjust timezone in data
Input:
.utc_timestamp | localtime
Output:
Convert UTC field to local time
Create local time versions
Input:
map({local_time: .timestamp | localtime})
Output:
Add local time field

The localtime() function converts a timestamp from UTC to the local timezone, adjusting the time value accordingly.

Usage

Use localtime() to convert UTC timestamps to local time, display times in the user’s timezone, or adjust timestamps for local time calculations.