0
私はチャットアプリを開発中です。私は、UTCのタイムゾーンとデバイスの現在のタイムゾーンの間の時間差を決定したいと思います。 swift3でそれを行うには?即時のutcタイムゾーンとデバイスタイムゾーンの差
私はチャットアプリを開発中です。私は、UTCのタイムゾーンとデバイスの現在のタイムゾーンの間の時間差を決定したいと思います。 swift3でそれを行うには?即時のutcタイムゾーンとデバイスタイムゾーンの差
// Returns a Date initialized to the current date and time
let currentDate = Date()
// Returns the time zone currently used by the system
let timeZone = NSTimeZone.system
// Returns the difference in seconds between the receiver and Greenwich Mean Time at a given date.
let timeZoneOffset = timeZone.secondsFromGMT(for: currentDate)/3600
print(timeZoneOffset, "hours offset for timezone", timeZone)
// example output for Denver (considers daylight saving time)
// -6 hours offset for timezone America/Denver (current)