iOS Swift - Get the Current Local Time and Date Timestamp

后端 未结 8 1730
鱼传尺愫
鱼传尺愫 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 17:05

    For saving Current time to firebase database I use Unic Epoch Conversation:

    let timestamp = NSDate().timeIntervalSince1970
    

    and For Decoding Unix Epoch time to Date().

    let myTimeInterval = TimeInterval(timestamp)
    let time = NSDate(timeIntervalSince1970: TimeInterval(myTimeInterval))
    

提交回复
热议问题