//--- Convert NSDate to Date String ---//
func dateformatterDate(date: NSDate) -> NSString
{
var dateFormatter: NSDateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "MM-dd-yyyy"
dateFormatter.timeZone = NSTimeZone(abbreviation: "UTC")
return dateFormatter.stringFromDate(date)
}
//--- Convert Date String to NSDate ---//
func dateformatterDateString(dateString: NSString) -> NSDate?
{
var dateFormatter: NSDateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "MM-dd-yyyy"
dateFormatter.timeZone = NSTimeZone(abbreviation: "UTC")
return dateFormatter.dateFromString(dateString)
}
You should have given an example with some string to which you are converting to date.
ReplyDeleteHow will you convert "2015-01-09 12:45:13" string into a date?
This seems to be returning the date after the one I have selected in the picker.. Is there something I may have overlooked?
ReplyDelete