How to change time and timezone in iPhone simulator?

Solution 1:

I'm guessing it uses your system timezone, so changing the TZ in System Preferences would probably do the trick

Screenshot for description

Solution 2:

You can set the TZ environment variable in an Xcode Scheme to set the time zone just for that app.

Manage Schemes

You can use UTC, PST, EST, as well as place-based timezone names such as America/Los_Angeles. It's not well documented, but I suspect any time zone name should work.

It's not well documented, but the source is an Apple Developer Support rep on the developer forums.

Solution 3:

Restart the Simulator after changing the system date time preferences and you shall see the changes reflected. It worked for me.

Solution 4:

It would be useful if Apple provided a "Simulate date" as they provided a "Simulate Location" menu. What I do is set a breakpoint immediately after getting the date (saving it in a variable) and then modify the value. Or just modify the spot where I check for a date change and make it return true.