I ran into a problem because I am running swift 2 NOT 3. (now I am updating the code)
here is the fix for the code above so people can see the changes from Swift 2 to Swift 3
import UIKit let formatter = NSDateFormatter() formatter.dateFormat = "yyy/MM/dd" formatter.calendar = NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian) let date = NSDate() let dateInGrogrian = formatter.stringFromDate(date) print("Date in Grogrian = \(dateInGrogrian)") formatter.calendar = NSCalendar(calendarIdentifier: NSCalendarIdentifierPersian) formatter.dateFormat = "yyy/MM//dd" print("Converted date to Jalali = \(formatter.stringFromDate(date))")
source share