How to convert date and time to a string using DateFormatter in Swift

1 Answer

0 votes
import Foundation

let today = Date()
let df = DateFormatter()

df.dateStyle = .short

let s = df.string(from: today)

print(s)




/*
run:

6/18/21

*/

 



answered Jun 18, 2021 by avibootz
...