How to Change Time and Timezone in iPhone Simulator

How to Change Time and Timezone in iPhone Simulator

Written by

in

Quick answer: The iPhone Simulator inherits your Mac’s system timezone by default. To change it globally, adjust the timezone in macOS System Settings. To change it only for a specific app, add a TZ environment variable (e.g., UTC, America/Los_Angeles) in the app’s Xcode scheme Run arguments.

Why this happens

The iPhone Simulator does not maintain its own independent clock or timezone database. Instead, it reads the host Mac’s current timezone setting at launch and applies it to the simulated device. This design keeps the simulator lightweight but means there is no built-in Settings app toggle inside the simulator itself to adjust the clock.

Because the simulator mirrors the host, any change to the Mac’s timezone immediately affects all running and future simulator instances. That behavior is fine for general development but problematic when you need to test timezone-specific logic—such as calendar rendering, timestamp formatting, or scheduled notifications—without altering your entire Mac environment.

Apple’s Developer Support has confirmed that the simulator also respects the TZ environment variable when it is set for a specific process. This allows per-app timezone overrides without touching the system clock.

How to fix it

1. Change the timezone for a single app via Xcode Scheme (recommended)

This method isolates the timezone change to one app run, leaving your Mac and other simulators unaffected.

  1. Open your project in Xcode.
  2. Choose Product > Scheme > Edit Scheme… (or press ⌘<).
  3. Select Run in the left sidebar, then the Arguments tab.
  4. Under Environment Variables, click the + button.
  5. Set Name to TZ and Value to the desired timezone identifier.
    – Examples: UTC, PST, EST, America/Los_Angeles, Europe/Paris, Asia/Tokyo.
    – Use the IANA tz database names (the same ones found in /usr/share/zoneinfo).
  6. Ensure the checkbox is enabled, then click Close.
  7. Build and run the app in the simulator. The app will now see the specified timezone.
Name: TZ
Value: America/New_York

Tip: You can create duplicate schemes (e.g., “Run UTC”, “Run Tokyo”) to switch quickly between timezones without editing the scheme each time.

2. Change the system timezone for all simulators

If you prefer a global change or need the simulator’s status bar clock to reflect a different zone:

  1. Open System Settings > General > Date & Time on macOS.
  2. Turn off Set time zone automatically using your current location.
  3. Click the timezone map or search field and select the desired zone.
  4. Relaunch any running simulators (cold boot: Device > Erase All Content and Settings… or simply quit and reopen the Simulator app).

All simulators will now report the new system timezone to every app.

3. Verify the timezone inside your app

Add a quick debug line to confirm the active timezone at runtime:

import Foundation

print("Current timezone: \(TimeZone.current.identifier)")
print("Abbreviation: \(TimeZone.current.abbreviation() ?? "n/a")")
print("Offset from UTC: \(TimeZone.current.secondsFromGMT() / 3600) hours")

Run the app with each scheme or system setting to validate the change.

How to prevent it

  • Use scheme-based TZ overrides for CI pipelines and local feature work; they keep your Mac clock correct.
  • Name schemes clearly (e.g., AppName (UTC), AppName (PST)) so teammates know which timezone is active.
  • Avoid hardcoding timezone identifiers in production code; rely on TimeZone.current or user preferences.
  • Reset the simulator after a system timezone change if the status bar clock doesn’t update immediately.

FAQ

Does the TZ environment variable affect the simulator’s status bar clock?

No. The status bar clock always follows the host Mac’s system timezone. The TZ variable only changes the timezone reported by TimeZone.current and related APIs inside the debugged app process.

Can I simulate a specific date and time, not just the timezone?

The simulator does not expose a built-in way to freeze or offset the clock. For fixed-date testing, inject a clock protocol into your code (e.g., DateProvider) and swap implementations in tests or preview providers.

Will the TZ variable persist across simulator reboots?

Yes, as long as the scheme remains selected. The variable is part of the scheme definition stored in the project or workspace (xcscheme files), so it survives simulator restarts and Mac reboots.

Summary

  • Per-app override: Add TZ=America/Los_Angeles (or any IANA zone) to the Run scheme’s Environment Variables.
  • Global override: Change the Mac’s timezone in System Settings > Date & Time, then relaunch the simulator.
  • Verify with TimeZone.current.identifier in your code.

Choose the scheme method for isolated, repeatable timezone testing without disrupting your development machine.

Sources & credits

Parts of this guide are adapted from content licensed under CC BY-SA 4.0; this article is shared under the same license.