Swift – 日付操作

let now = NSDate() // 現在日時の取得
let dateFormatter = NSDateFormatter()

dateFormatter.locale = NSLocale(localeIdentifier: "ja_JP") // ロケールの設定
dateFormatter.timeStyle = .LongStyle
dateFormatter.dateStyle = .LongStyle
println(dateFormatter.stringFromDate(now)) // -> 2014年6月24日 11:14:17 JST

      

コメント

タイトルとURLをコピーしました