8

Is there a way to change the date in the simulator to simulate for example Dec.02.2018, Feb.03.2018? I need to check if the code I have will react correctly given the date.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Tom
  • 99
  • 1
  • 7
  • 2
    Possible duplicate of [How to change time and timezone in iPhone simulator?](https://stackoverflow.com/questions/1699671/how-to-change-time-and-timezone-in-iphone-simulator) – Martin R Jul 22 '17 at 20:16
  • @Martin R perhaps you are able to help.....I want only to change the date to one I choose not time zone or time do you know if there is a way to do it other than playing with the system date as was proposed by Mohammad Sadiq? – Tom Jul 22 '17 at 20:35

2 Answers2

10

Xcode 11 brought the ability to change the date (and time) using the simctl command line tool:

xcrun simctl status_bar booted override --time "2007-01-09T09:41:00-08:00"

The date and time is in the ISO 8601 format. Make sure to adjust the time zone if you want the clock to show the given time ("-08:00" is for PST/California, "+01:00" for Western Europe, ...).

davidisdk
  • 3,358
  • 23
  • 12
  • 7
    This won't change the time value, it just changes the status bar display for a screenshot: https://stackoverflow.com/a/57834594/96944 – Jannie Theunissen Nov 23 '20 at 06:24
6

Change your mac system date and time. It would get reflected in simulator. Go to 'System Preferneces' -> Date and Time.

Mohammad Sadiq
  • 5,070
  • 28
  • 29
  • 2
    many thanks for you very quick reply to my question....is there no way to do it other than changing the system date? – Tom Jul 22 '17 at 20:19
  • I don't know the complete requirement. We don't have an option to Simulate Date and Time. You can try programatically different dates, if that serves your purpose. – Mohammad Sadiq Jul 22 '17 at 20:25
  • If you need to change the actual, system time of the simulator for testing an app at a specific time of day, this is really the only option. The simctl commands above only change the status bar display, not the actual, system time. – dbDev Jul 10 '22 at 18:23
  • This works but it also breaks the internet for you. Tested both Firefox and Chrome and I get the same error: ```Your Computer Clock is Wrong Your computer thinks it is Feb 15, 2023, which prevents Firefox Developer Edition from connecting securely.``` – philbert Jul 24 '23 at 15:13