SwiftMoment
SwiftMoment copied to clipboard
How to get the UTC time?
In momentjs, we simply do moment().utc().format()
, how would we accomplish this in SwiftMoment?
For completion, this is what I ended up doing using Date()
and TimeFormatter()
let UTCDate = Date()
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss'Z'"
formatter.timeZone = TimeZone(secondsFromGMT:0)
let utcTime = formatter.string(from: UTCDate)
Thank you