There seem to be five date styles for the DateFormatter class: none, short, medium, long, and full. However, none of these seem to return the lock screen date style, which is as follows:
Tuesday, 6 June
Using DateFormatter's .long
style returns the year as well:
Tuesday, 6 June 2017
Additionally, this lock screen date style will change with the current localization/regional settings.
Is there a way to return the date, à la iOS lock screen date style (along with localizational changes)?
答案 0 :(得分:2)
答案 1 :(得分:1)
You can use the custom date format "EEEE, d MMMM"
Swift 3
let date = Date()
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "EEEE, d MMMM"
dateFormatter.string(from: date)
// Friday, 4 August