iphone - How to get the timezone of a location in iOS app? -


i new ios development. trying build app can 2 things:

a. get user's system time (say, phone in london, time)

b. get time in given location (say, san francisco)

and then, want calculate difference in time between location (e.g. london, uk 8 hours ahead of san francisco, ca)

can please me suggestions how can (a) , (b)?

for both (a) , (b):

      let offset = timezone.current.secondsfromgmt();          print(offset)//your current timezone offset in seconds          let loc = cllocation.init(latitude: 48.8566, longitude: 2.3522);//paris's lon/lat           let coder = clgeocoder();         coder.reversegeocodelocation(loc) { (placemarks, error) in             let place = placemarks?.last;              let newoffset = place?.timezone?.secondsfromgmt();              print(newoffset);//paris's timezone offset in seconds         } 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -