PHP error guide
It is not safe to rely on system timezone: meaning and fix
Error summary
Set date.timezone to a valid IANA identifier or call date_default_timezone_set early. Older PHP date functions run without a configured default timezone.
What it means
Set date.timezone to a valid IANA identifier or call date_default_timezone_set early. Older PHP date functions run without a configured default timezone.
What the error means
This message means that older PHP date functions run without a configured default timezone. The exact signature distinguishes it is not safe to rely on system timezone from a generic application failure.
Why PHP produces it
The engine or service reports “It is not safe to rely on system timezone” because its required precondition was not met. Set date.timezone to a valid IANA identifier or call date_default_timezone_set early.
PHP version notes
The it is not safe to rely on system timezone wording here is based on PHP 7.x–8.4; exception forms require JSON_THROW_ON_ERROR where shown; punctuation and exception class names can differ on older branches or vendor builds.
Most common causes
- The immediate input or configuration reaches the specific condition: older PHP date functions run without a configured default timezone
- The code path assumes the prerequisite for it is not safe to rely on system timezone has already been satisfied.
- For it is not safe to rely on system timezone, development and production differ in version, extension, permissions, paths, or service configuration.
- An earlier operation returned an unchecked value that is consumed by the line reporting it is not safe to rely on system timezone.
Minimal examples
BAD — reproduces the problem
echo date("c");
FIXED — safer pattern
date_default_timezone_set("UTC");
echo date("c");
Step-by-step diagnosis
- Copy the complete “Warning: date(): It is not safe to rely on the system's timezone settings” text and retain the first application stack frame.
- Reproduce it is not safe to rely on system timezone in the same SAPI and environment listed for this page.
- Before changing it is not safe to rely on system timezone, inspect the preceding value or directive and verify its type, path, version, and permissions.
- Apply the narrow correction—set date.timezone to a valid IANA identifier or call date_default_timezone_set early—then repeat the original request once.
Fixes
Correct the failing prerequisite
Set date.timezone to a valid IANA identifier or call date_default_timezone_set early
date_default_timezone_set("UTC");
echo date("c");
Fail explicitly at the boundary
Validate the condition before the operation that emits it is not safe to rely on system timezone, and log a safe diagnostic without credentials or full production paths.
Common mistakes when fixing it
- Suppressing it is not safe to rely on system timezone instead of correcting its upstream condition.
- Testing it is not safe to rely on system timezone only with the CLI binary when the failing request runs under FPM or Apache.
- Changing a global setting for it is not safe to rely on system timezone before confirming the site-specific effective configuration.
How to prevent it
- Add a focused test that exercises the boundary responsible for it is not safe to rely on system timezone.
- Keep runtime versions, extensions, configuration, and deploy artifacts affecting it is not safe to rely on system timezone reproducible.
- Validate external data and service return values before they can trigger it is not safe to rely on system timezone.
Web server / environment notes
cli, fpm, linux. The failure occurs where older PHP date functions run without a configured default timezone
Tags: cli,fpm,linux