如何不使用Date.now将DateFormatter转换为字符串?
发布于 2022-11-10 13:41:56
使用新的.formatted()语法:
Date.now.formatted()
Date.now.formatted(date: .abbreviated, time: .omitted)诸若此类。
发布于 2022-11-10 13:45:07
是。你可以:
let date = Date()
let dateString = date.formatted()
print("Today is \(dateString), also work with \(date) directly.")但是您错过了控件来格式化日期;-)
编辑:对不起,我同时回复了@jrturton
https://stackoverflow.com/questions/74389968
复制相似问题