LoginSignup
46

More than 5 years have passed since last update.

posted at

[Swift]現在時刻の取得

SwiftでNSDateを使って現在時刻を取得してみました。

コード

let now = NSDate()

let formatter = NSDateFormatter()
formatter.dateFormat = "yyyy/MM/dd HH:mm:ss"

let string = formatter.stringFromDate(now)

println(string)

出力結果

2014/07/28 17:11:29

まとめ

現在時刻を取得する、ここまではObjective-Cの時と特に変わりは無いようです。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
46