iOS Swift - Get the Current Local Time and Date Timestamp

后端 未结 8 1734
鱼传尺愫
鱼传尺愫 2020-12-23 16:08

I\'m trying to make an attendance app and I am really confused about date and time in iOS and Firebase.

I use date as Key, this is the structure of my Firebase datab

8条回答
  •  借酒劲吻你
    2020-12-23 16:48

    in Swift 5

    extension Date {
        static var currentTimeStamp: Int64{
            return Int64(Date().timeIntervalSince1970 * 1000)
        }
    }
    

    call like this:

    let timeStamp = Date.currentTimeStamp
    print(timeStamp)
    

    Thanks @lenooh

提交回复
热议问题