The Default Time Zone
Every Pixeltable deployment has a default time zone. The default time zone can be configured either by setting thePIXELTABLE_TIME_ZONE
environment variable, or by adding a time-zone entry to the
[pixeltable] section in $PIXELTABLE_HOME/config.toml. It must be a
valid IANA Time
Zone.
(See the Pixeltable
Configuration guide
for more details on configuration options.)
datetime object may be either naive (no time zone) or
aware (equipped with an explicit time zone). Pixeltable will always
interpret naive datetime objects as belonging to the configured
default time zone.
Insertion and Retrieval
When adatetime is inserted into the database, it will be converted to
UTC and stored as an absolute timestamp. If the datetime has an
explicit time zone, Pixeltable will use that time zone for the
conversion; otherwise, Pixeltable will use the default time zone.
When a datetime is retrieved, it will always be retrieved in the
default time zone. To query in a different time zone, it is necessary to
do an explicit conversion; we’ll give an example of this in a moment.
Let’s first walk through a few examples that illustrate the default
behavior.
| dt | note |
|---|---|
| 2024-08-09 23:00:00-07:00 | No time zone specified (uses default) |
| 2024-08-09 23:00:00-07:00 | Time zone America/Los_Angeles was specified explicitly |
| 2024-08-09 20:00:00-07:00 | Time zone America/New_York was specified explicitly |
astimezone
method.
| dt | dt_new_york | note |
|---|---|---|
| 2024-08-09 23:00:00-07:00 | 2024-08-10 02:00:00-04:00 | No time zone specified (uses default) |
| 2024-08-09 23:00:00-07:00 | 2024-08-10 02:00:00-04:00 | Time zone America/Los_Angeles was specified explicitly |
| 2024-08-09 20:00:00-07:00 | 2024-08-09 23:00:00-04:00 | Time zone America/New_York was specified explicitly |
Timestamp Methods and Properties
The Pixeltable API exposes all the standarddatetime methods and
properties from the Python library. Because retrieval uses the default
time zone, they are all relative to the default time zone unless
astimezone is used.
| dt | day_default | day_eastern |
|---|---|---|
| 2024-08-09 23:00:00-07:00 | 9 | 10 |
| 2024-08-09 23:00:00-07:00 | 9 | 10 |
| 2024-08-09 20:00:00-07:00 | 9 | 9 |