date_to_utc()
Convert a wall-clock datetime to UTC. Record datetime fields are stored in UTC, so use this before writing a human-entered time into one.
Syntax
date_to_utc(datetime, timezone?)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
datetime |
string | yes | A datetime in any format strtotime understands. |
timezone |
string | no | The source timezone (e.g. America/New_York). Defaults to the account owner's timezone. |
Returns
The datetime in UTC as YYYY-MM-DD HH:MM:SS. A date-only input (no time) is returned unchanged.
Example
// Owner is in America/New_York; store 9am local as UTC.
$utc = date_to_utc("2026-06-12 09:00:00");
record_update("events", $record["_meta"]["id"], ["starts_at" => $utc]);
Example output
"2026-06-12 13:00:00"
Notes
- Parsing is forgiving — any format
strtotimeaccepts works. Throws if it can't parse the value. - The inverse is date_from_utc().
See also: date_from_utc(), sys_current_datetime()