How to get time (hour, minute, second) in Swift 3 using NSDate?

前端 未结 10 2627
孤独总比滥情好
孤独总比滥情好 2020-11-28 05:16

How can you determine the hour, minute and second from NSDate class in Swift 3?

In Swift 2:

let date = NSDate()
let calendar = NSCalendar.currentCale         


        
10条回答
  •  误落风尘
    2020-11-28 05:51

    let hours = time / 3600
    let minutes = (time / 60) % 60
    let seconds = time % 60
    return String(format: "%0.2d:%0.2d:%0.2d", hours, minutes, seconds)
    

提交回复
热议问题