How to get the month name from the current date in Swift

1 Answer

0 votes
import Foundation

let date = Date()

let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "MMMM"

let monthName = dateFormatter.string(from: date)
print(monthName) 



/*
run:

January

*/

 



answered Jan 8, 2025 by avibootz
...