Getting the City & Country list in iOS Time Zone

后端 未结 4 1792
梦毁少年i
梦毁少年i 2021-01-05 01:02

I want to get access to the user-friendly Time Zone list that appears in the Settings > General > Date & Time. Can someone help in providing the code for this?

S

4条回答
  •  Happy的楠姐
    2021-01-05 01:29

    Try this:

    let timezone = TimeZone.current.identifier
    

    This will return "America/Sao_Paulo".

    Sorry, this will get all list:

    let array = TimeZone.knownTimeZoneIdentifiers
    

提交回复
热议问题