2016-04-13 26 views
-1

私は自分の日付をフォーマットする必要があります。 Iこのコードを持っている:NSDateFormatで日付をフォーマットするにはどうすればよいですか?

func recuperaData() -> String? { 

let data = NSDateFormatter.localizedStringFromDate(NSDate(), dateStyle: .ShortStyle, timeStyle: .ShortStyle) 
    return "\(data)" 
} 

このコードは、私にこのような文字列が返されます。

を2016年4月13日、10:50 AMの代わりに私が13/04/2016、10:50

をしたいです

何をする必要がありますか?

答えて

1

使用NSDateFormatter

func recuperaData() -> String? 
{ 
    let dateFormatter = NSDateFormatter() 
    dateFormatter.dateFormat = "dd/MM/yyyy, HH:mm" 
    let selecteddate = dateFormatter.stringFromDate(NSDate()) 
    return selecteddate 
} 
関連する問題