date_from_utc()

Convert a UTC datetime to a local timezone — useful when formatting a stored datetime field for an email or comment.

Syntax

date_from_utc(datetime, timezone?)

Parameters

Name Type Required Description
datetime string yes A UTC datetime in any format strtotime understands.
timezone string no The target timezone (e.g. Europe/London). Defaults to the account owner's timezone.

Returns

The datetime in the target timezone as YYYY-MM-DD HH:MM:SS. A date-only input is returned unchanged.

Example

$local = date_from_utc($record["starts_at"], "Europe/London");
record_comment("events", $record["_meta"]["id"], "Starts at " . $local . " London time");

Example output

"2026-06-12 14:00:00"

Notes

  • Parsing is forgiving; throws if the value can't be parsed.
  • The inverse is date_to_utc().

See also: date_to_utc(), sys_current_datetime()