krishna
krishna

Reputation: 23

How to change the time format in calendar swift 3

I am using FSCalendar for my project. When I click any date in calendar.It displays previous date in console.How Can I solve this issue.Please help me.for example when I click 2017-11-28 date, It displays selected date is:2017-11-27 18:30:00 +0000

Upvotes: 0

Views: 545

Answers (1)

Subrat Padhi
Subrat Padhi

Reputation: 126

Set the FSCalendar deleget and try this code:

func calendar(_ calendar: FSCalendar, shouldSelect date: Date, at monthPosition: FSCalendarMonthPosition) -> Bool {
    let dateFormatter = DateFormatter()
    dateFormatter.dateFormat = "dd-MM-yyyy"
    let dateString = dateFormatter.string(from: date as Date)
    print("Selected Date: \(dateString)")
    return true
}

Upvotes: 1

Related Questions