How To Get Current Date Swift Programmatically

Sometimes you need to get the current date in Swift.

How To Get Current Date In Swift

To get the current date, create a new Date instance.

let date = Date()

You can print the current date using a DateFormatter

let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "dd/MM/yyyy"
print(dateFormatter.string(from: date))
If you liked this post and want to learn more, check out The Complete iOS Developer Bootcamp. Speed up your learning curve - hundreds of students have already joined. Thanks for reading!

Eddy Chung

I teach iOS development on ZeroToAppStore.com.

Similar Posts