Local time is an estimate of the standard time at the device’s location, aka "wall clock time". Local time is derived from UTC and time zone. Local time is more complex and has more failure modes than the other time standards so as a developer you should prefer monotonic or UTC time unless there is an explicit need to use local time. Please refer to time overview for more information on choosing between time standards and UTC overview for more information on the implementation and behavior of UTC for Fuchsia.
Time zone is maintained as one component of the internationalization settings
setui_service (for more information, see
intl_services exposes a more
FIDL interface that you may use to read the preferred time zone, read any
optional alternate time zones, and receive time zone change events.
Low level language runtimes such as C, C++, and Rust do not directly implement
local time because that would have required a dependency on
fuchsia.intl.PropertyProvider and ICU from all components written in these
functions in the Fuchsia musl implementation always return a UTC time. If you
need to use local time from these languages you should use
to read the preferred timezone, use the
ICU timezone data to
determine the timezone offset, and then apply this offset to the current UTC
The Dart and Flutter runners do support local time directly (because they are
wired up to a
fuchsia.intl.PropertyProvider). If you are writing a Dart or
Flutter component you may use
to read the current local time. The intl/timezone
tests ensure that a Dart component on a Fuchsia device can read the same local
time as a host device.
As with UTC, a Fuchsia device cannot produce a valid local time until it has received a valid time from either the network or a real time clock. The time zone is usually set based on user input so you should assume that the time zone may change at any time and that the timezone is potentially inaccurate (i.e. the reported time zone may not match the legally defined civil time at the device's present location). Local time may jump either forwards or backwards, for example at daylight savings time transitions.