ios 获取当前时间 格式是 MM-dd HHmmss
您可以使用以下代码来获取当前时间,并将其格式化为 MM-dd HH:mm:ss 的格式:
let currentDate = Date()
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "MM-dd HH:mm:ss"
let formattedDate = dateFormatter.string(from: currentDate)
print(formattedDate)
这将打印出当前时间的格式化字符串。请注意,您还可以根据需要进行其他自定义,例如更改日期格式或使用不同的时区。
原文地址: http://www.cveoy.top/t/topic/iXHD 著作权归作者所有。请勿转载和采集!