I'm looking for a way to display the current GMT-0 time.
So far, I've been doing it like:
let UTCDate = Date()
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
let defaultTimeZoneStr = formatter.string(from: UTCDate)
However it returns the current time of the phone.
How can I get the current GMT-0 time using Swift 3?
Before the last line of your code, insert this line:
formatter.timeZone = TimeZone(secondsFromGMT:0)
Or this line:
formatter.timeZone = TimeZone(identifier:"GMT")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With