iOS Swift - Get the Current Local Time and Date Timestamp

后端 未结 8 1753
鱼传尺愫
鱼传尺愫 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:56

    The simple way to create Current TimeStamp. like below,

    func generateCurrentTimeStamp () -> String {
        let formatter = DateFormatter()
        formatter.dateFormat = "yyyy_MM_dd_hh_mm_ss"
        return (formatter.string(from: Date()) as NSString) as String
    }
    

提交回复
热议问题