Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the City & Country list in iOS Time Zone

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?

Settings > General > Data & Time > Time Zone (Selection)

like image 706
Rijaz Ali Avatar asked Nov 26 '17 08:11

Rijaz Ali


People also ask

How much is MRT ticket in Singapore?

The price of the Singapore MRT depends on the distance travelled. It varies between 1.50 SGD ( US$ 1.10) and 2.50 SGD ( US$ 1.80) per journey. If you want to save on transport, the best option is the EZ-Link card or the Singapore Tourist Pass.

How do I get from Changi to city?

To get to the city, take the train from Changi Airport MRT Station (CG2) to Tanah Merah MRT Station (EW4), then transfer to the East West Line towards Tuas Link MRT Station (EW33).

Is Singapore MRT 24 hours?

Train Operation Hours and Frequency5.30am to around midnight daily. Operating hours are usually extended during festive periods.


1 Answers

Swift 4

Get the current user time zone:

let currentTimeZone = TimeZone.current

Get all time zones:

let timeZoneIdentifiers = TimeZone.knownTimeZoneIdentifiers

Create time zone with identifier:

let berlin = TimeZone(identifier: "Europe/Berlin")!

Get city name of time zone:

let cityName = berlin.identifier.split(separator: "/").last!

Get all city names:

    let allCities = timeZoneIdentifiers.compactMap { identifier in
        return identifier.split(separator: "/").last
    }
like image 155
Marceeelll Avatar answered Sep 27 '22 22:09

Marceeelll