Juste votre décès, votre dateformate
) et de votre date, puis vous obtenez Year,month,day,hour
. Des infos supplémentaires
func GetOnlyDateMonthYearFromFullDate(currentDateFormate:NSString , conVertFormate:NSString , convertDate:NSString ) -> NSString
{
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = currentDateFormate as String
let formatter = NSDateFormatter()
formatter.dateFormat = Key_DATE_FORMATE as String
let finalDate = formatter.dateFromString(convertDate as String)
formatter.dateFormat = conVertFormate as String
let dateString = formatter.stringFromDate(finalDate!)
return dateString
}
Obtenez De L'Année
let Year = self.GetOnlyDateMonthYearFromFullDate("yyyy-MM-dd'T'HH:mm:ssZ", conVertFormate: "YYYY", convertDate: "2016-04-14T10:44:00+0000") as String
Obtenir Mois
let month = self.GetOnlyDateMonthYearFromFullDate("yyyy-MM-dd'T'HH:mm:ssZ", conVertFormate: "MM", convertDate: "2016-04-14T10:44:00+0000") as String
Obtenir Jour
let day = self.GetOnlyDateMonthYearFromFullDate("yyyy-MM-dd'T'HH:mm:ssZ", conVertFormate: "dd", convertDate: "2016-04-14T10:44:00+0000") as String
Obtenez De L'Heure
let hour = self.GetOnlyDateMonthYearFromFullDate("yyyy-MM-dd'T'HH:mm:ssZ", conVertFormate: "hh", convertDate: "2016-04-14T10:44:00+0000") as String