Edit

Share via


datetime_utc_to_local()

Applies to: ✅ Microsoft FabricAzure Data ExplorerAzure MonitorMicrosoft Sentinel

Converts UTC datetime to local datetime using a time-zone specification.

Syntax

datetime_utc_to_local(from,timezone)

Learn more about syntax conventions.

Note

datetime_utc_to_local() is a built-in Kusto function and does not require importing any additional libraries. If you receive an error that the function does not exist, confirm that you're running the query in a supported environment (Azure Data Explorer, Microsoft Sentinel, Azure Monitor, Microsoft Fabric).

Parameters

Name Type Required Description
from datetime ✔️ The UTC datetime to convert.
timezone string ✔️ The timezone to convert to. This value must be one of the supported timezones.

Returns

Returns a local datetime in the timezone that corresponds the UTC datetime.

Examples

The following example shows how to convert a UTC datetime to local datetime.

print dt=now()
| extend pacific_dt = datetime_utc_to_local(dt, 'US/Pacific'), canberra_dt = datetime_utc_to_local(dt, 'Australia/Canberra')
| extend diff = pacific_dt - canberra_dt

Output

dt pacific_dt canberra_dt diff
2022-07-11 22:18:48.4678620 2022-07-11 15:18:48.4678620 2022-07-12 08:18:48.4678620 -17:00:00