- 主要知识点
- 实现代码
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let date = Date()
let timeFormatter = DateFormatter()
//日期显示格式,可按自己需求显示
timeFormatter.dateFormat = "yyy-MM-dd' at 'HH:mm:ss.SSS"
let strNowTime = timeFormatter.string(from: date) as String
print(strNowTime)
}
- 运行结果
2017-02-12 at 22:43:34.664