Reputation: 7370
I have CoreData
myDate = date, Entity column and returns output:
let mydate = coreDataValues[0].myDate!
print(mydate)
OUTPUT == 2017-02-01 12:45:40 +0000
I want to convert mydate
to datetime
under below like , example ;
2017-12-20-23-59-59
How can I do it ?
Ty
Upvotes: 0
Views: 1389
Reputation: 814
You can do it like this:
var dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd-HH-mm-ss"
var date = dateFormatter.string(from: mydate as Date)
print(date)
OUTPUT = 2017-02-01-18-10-01
Upvotes: 4