Reputation: 49
How can I find the current time and it's region if i have current location, latitude and longitude?
I can get any city of any country as current location and having latitude and longitude of it and have to get current time and region of it. Then how to find current time and region based on that.
Upvotes: 3
Views: 654
Reputation: 57169
You will need a service such as Geonames timesezone and then adjust the NSDate
to that timezone offset. The method dateWithCalendarFormat:timeZone:
can be used with the date returned from [NSDate date]
.
Edit:
That webservice provides timezone offsets. dstOffset would be best in most situations since it accounts for daylight savings time otherwise use gmtOffset. NSTimeZone
object can be created by using the static method + (id)timeZoneForSecondsFromGMT:(NSInteger)seconds
and converting the offset from hours to seconds.
Upvotes: 2
Reputation: 135540
[NSDate date]
will return a NSDate
object with the current date and time.
Upvotes: 0