+
Skip to content
This repository was archived by the owner on Feb 3, 2020. It is now read-only.
This repository was archived by the owner on Feb 3, 2020. It is now read-only.

How to get the UTC time? #95

@VicFrolov

Description

@VicFrolov

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载