SwiftMoment icon indicating copy to clipboard operation
SwiftMoment copied to clipboard

How to get the UTC time?

Open VicFrolov opened this issue 7 years ago • 0 comments

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

VicFrolov avatar Sep 12 '17 23:09 VicFrolov