0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

現在時間の取得(Date)

Last updated at Posted at 2021-09-06

今回の内容

  • 今回の取得方法は私自身が使用したものだけを投稿していますので、他の取得方法などは調べていただいた方が詳しい情報が得られると思います。
C1260E4F-6F02-42B3-9EAE-93478CF9D903_1_201_a.jpeg

コードと簡単解説

  • UILabelを作成しておきます。
@IBOutlet weak var currentDateLabel: UILabel!
  • 時間の取得を行います。
  • .dateStyle.timeStyleで取得してくる形を決めます。種類は.full.long.medium.none.shortがあります。
currentDateLabel.text = {() -> String in
            
            let formatter = DateFormatter()
            formatter.dateStyle = .full
            formatter.timeStyle = .medium
            formatter.locale = Locale(identifier: "ja_JP")
            let date = Date()
            return formatter.string(from:  date)
        }()

終わり

ご指摘、ご質問などありましたら、コメントまでお願い致します。

0
1
0

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
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?